class TestCommonWords

Constants

ROOT

Public Instance Methods

setup() click to toggle source
# File test/test_common_words.rb, line 13
def setup
  @words = CW::CommonWords.new
end
teardown() click to toggle source
# File test/test_common_words.rb, line 17
def teardown
  @words = nil
end
test_all_returns_all_words() click to toggle source
# File test/test_common_words.rb, line 64
def test_all_returns_all_words
  words = @words.read(:all)
  assert_equal 10000, words.size
  assert_equal 'the',words[0]
  assert_equal 'poison',words[-1]
end
test_parse_quantity_for_1() click to toggle source
# File test/test_common_words.rb, line 21
def test_parse_quantity_for_1
  assert_equal [0], @words.parse_quantity(1)
end
test_parse_quantity_for_2() click to toggle source
# File test/test_common_words.rb, line 25
def test_parse_quantity_for_2
  assert_equal [0,1], @words.parse_quantity(2)
end
test_parse_quantity_for_no_argument() click to toggle source
# File test/test_common_words.rb, line 37
def test_parse_quantity_for_no_argument
  assert_equal [0, 999], @words.parse_quantity()
end
test_parse_quantity_for_range_1_2() click to toggle source
# File test/test_common_words.rb, line 29
def test_parse_quantity_for_range_1_2
  assert_equal [0,1], @words.parse_quantity(1..2)
end
test_parse_quantity_for_range_2_3() click to toggle source
# File test/test_common_words.rb, line 33
def test_parse_quantity_for_range_2_3
  assert_equal [1,2], @words.parse_quantity(2..3)
end
test_read_returns_100_words_for_no_argument() click to toggle source
# File test/test_common_words.rb, line 53
def test_read_returns_100_words_for_no_argument
  assert_equal 1000, @words.read().size
end
test_read_returns_500_words_for_range_100_to_1600() click to toggle source
# File test/test_common_words.rb, line 57
def test_read_returns_500_words_for_range_100_to_1600
  words = @words.read(100...1600)
  assert_equal 1500, words.size
  assert_equal 'find',words[0]
  assert_equal 'phentermine',words[-1]
end
test_read_returns_the_with_argument_1() click to toggle source
# File test/test_common_words.rb, line 41
def test_read_returns_the_with_argument_1
  assert_equal ['the'], @words.read(1)
end
test_read_returns_the_with_argument_2() click to toggle source
# File test/test_common_words.rb, line 45
def test_read_returns_the_with_argument_2
  assert_equal ['the','of'], @words.read(2)
end
test_read_returns_the_with_range_2_3() click to toggle source
# File test/test_common_words.rb, line 49
def test_read_returns_the_with_range_2_3
  assert_equal ['of','and'], @words.read(2..3)
end