Sha256: 7e38e4517149217b75463df5cae087341806432179c4ed12ad8366508925ee6c

Contents?: true

Size: 944 Bytes

Versions: 9

Compression:

Stored size: 944 Bytes

Contents

require "minitest/autorun"

require "list_matcher"

class Stress < Minitest::Test
  def test_simple
    (1..10).each{ basic_test 5000, 97..122, 4..8 }
  end

  def test_fixed_size
    (1..10).each{ basic_test 5000, 97..122, 8..8 }
  end

  def test_really_big
    basic_test 50000, 97..122, 4..8
  end

  def basic_test(n, range, max)
    words = words n, range, max
    good = words[0...n/10]
    bad = words[n/10..-1]
    rx = List::Matcher.rx( good, bound: true )
    puts good.inspect unless good.all?{ |w| rx === w }
    good.each do |w|
      assert rx === w, "#{w} is good for #{rx}"
    end
    bad.each do |w|
      assert !( rx === w ), "#{w} is bad for #{rx}"
    end
  end

  def words(n, range, max)
    words = []
    while words.size < n
      words += (1..n/10).map{ random_word range, max }
      words.uniq!
    end
    words[0...n]
  end

  def random_word(range, max)
    (1..rand(max)).map{ rand(range).chr }.join
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
list_matcher-1.1.8 test/stress.rb
list_matcher-1.0.7 test/stress.rb
list_matcher-1.0.6 test/stress.rb
list_matcher-1.0.5 test/stress.rb
list_matcher-1.0.4 test/stress.rb
list_matcher-1.0.3 test/stress.rb
list_matcher-1.0.2 test/stress.rb
list_matcher-1.0.1 test/stress.rb
list_matcher-1.0.0 test/stress.rb