class TestFiltering

Constants

ROOT

Public Instance Methods

setup() click to toggle source
# File test/test_filtering.rb, line 13
def setup
  @cw = Core.new
  @cw.no_run
end
teardown() click to toggle source
# File test/test_filtering.rb, line 18
def teardown
  @cw = nil
end
test_beginning_with_a() click to toggle source
# File test/test_filtering.rb, line 26
def test_beginning_with_a
  @cw.words = ['able', 'zero']
  @cw.beginning_with('a')
  assert_equal ['able'], @cw.words
end
test_beginning_with_ab() click to toggle source
# File test/test_filtering.rb, line 38
def test_beginning_with_ab
  @cw.words = ['ardvark', 'able', 'zero']
  @cw.beginning_with('ab')
  assert_equal ['able'], @cw.words
end
test_beginning_with_range() click to toggle source
# File test/test_filtering.rb, line 44
def test_beginning_with_range
  @cw.words = ['able', 'delta', 'zero']
  @cw.beginning_with('a'..'d')
  assert_equal ['able', 'delta'], @cw.words
end
test_beginning_with_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 56
def test_beginning_with_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.beginning_with('')
  assert_equal ['able', 'zero'], @cw.words
end
test_beginning_with_with_no_match() click to toggle source
# File test/test_filtering.rb, line 50
def test_beginning_with_with_no_match
  @cw.words = ['able', 'zero']
  @cw.beginning_with('b')
  assert_equal [], @cw.words
end
test_beginning_with_z() click to toggle source
# File test/test_filtering.rb, line 32
def test_beginning_with_z
  @cw.words = ['able', 'zero']
  @cw.beginning_with('z')
  assert_equal ['zero'], @cw.words
end
test_containing_abc() click to toggle source
# File test/test_filtering.rb, line 427
def test_containing_abc
  @cw.words = ['abd', 'abc', 'acb', 'cba', '123', 'ab', 'ad', 'cb']
  @cw.containing ['a','b','c']
  assert_equal ['abc', 'acb', 'cba', 'ab', 'cb'], @cw.words
end
test_containing_with_range() click to toggle source
# File test/test_filtering.rb, line 433
def test_containing_with_range
  @cw.words = ['abd', 'abc', 'acb', 'cba', '123', 'ab', 'ad', 'cb']
  @cw.containing ['a'..'c']
  assert_equal ['abc', 'acb', 'cba', 'ab', 'cb'], @cw.words
end
test_double_words() click to toggle source
# File test/test_filtering.rb, line 350
def test_double_words
  @cw.words = ['1', '12', '123']
  @cw.double_words
  assert_equal ['1', '1', '12', '12', '123', '123'], @cw.words
end
test_ending_with_a() click to toggle source
# File test/test_filtering.rb, line 98
def test_ending_with_a
  @cw.words = ['else', 'antenna', 'alba', 'zero']
  @cw.ending_with('a')
  assert_equal ['antenna', 'alba'], @cw.words
end
test_ending_with_range() click to toggle source
# File test/test_filtering.rb, line 116
def test_ending_with_range
  @cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
  @cw.ending_with('y'..'z')
  assert_equal ['may', 'kay', 'pizazz'], @cw.words
end
test_ending_with_tion() click to toggle source
# File test/test_filtering.rb, line 110
def test_ending_with_tion
  @cw.words = ['tiona', 'lion', 'station', 'creation']
  @cw.ending_with('tion')
  assert_equal ['station', 'creation'], @cw.words
end
test_ending_with_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 128
def test_ending_with_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.ending_with('')
  assert_equal ['able', 'zero'], @cw.words
end
test_ending_with_with_no_match() click to toggle source
# File test/test_filtering.rb, line 122
def test_ending_with_with_no_match
  @cw.words = ['able', 'zero']
  @cw.ending_with('b')
  assert_equal [], @cw.words
end
test_ending_with_z() click to toggle source
# File test/test_filtering.rb, line 104
def test_ending_with_z
  @cw.words = ['joy', 'pazazz']
  @cw.ending_with('z')
  assert_equal ['pazazz'], @cw.words
end
test_having_size_of_1() click to toggle source
# File test/test_filtering.rb, line 391
def test_having_size_of_1
  @cw.words = ['1', '12', '123']
  @cw.having_size_of 1
  assert_equal ['1'], @cw.words
end
test_having_size_of_2() click to toggle source
# File test/test_filtering.rb, line 397
def test_having_size_of_2
  @cw.words = ['1', '12', '23', '123']
  @cw.having_size_of 2
  assert_equal ['12','23'], @cw.words
end
test_having_size_of_3() click to toggle source
# File test/test_filtering.rb, line 403
def test_having_size_of_3
  @cw.words = ['1', '12', '23', '123']
  @cw.having_size_of 3
  assert_equal ['123'], @cw.words
end
test_including_a() click to toggle source
# File test/test_filtering.rb, line 170
def test_including_a
  @cw.words = ['else', 'banter', 'alt', 'zero']
  @cw.including('a')
  assert_equal ['banter', 'alt'], @cw.words
end
test_including_range() click to toggle source
# File test/test_filtering.rb, line 188
def test_including_range
  @cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
  @cw.including('g'..'k')
  assert_equal ['pizazz', 'kay'], @cw.words
end
test_including_tion() click to toggle source
# File test/test_filtering.rb, line 182
def test_including_tion
  @cw.words = ['tiona', 'lion', 'station', 'creation']
  @cw.including('tion')
  assert_equal ['tiona', 'station', 'creation'], @cw.words
end
test_including_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 200
def test_including_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.including('')
  assert_equal ['able', 'zero'], @cw.words
end
test_including_with_no_match() click to toggle source
# File test/test_filtering.rb, line 194
def test_including_with_no_match
  @cw.words = ['able', 'zero']
  @cw.including('c')
  assert_equal [], @cw.words
end
test_including_z() click to toggle source
# File test/test_filtering.rb, line 176
def test_including_z
  @cw.words = ['joy', 'amaze', '123']
  @cw.including('z')
  assert_equal ['amaze'], @cw.words
end
test_no_longer_than_1() click to toggle source
# File test/test_filtering.rb, line 242
def test_no_longer_than_1
  @cw.words = ['1', '12', '123']
  @cw.no_longer_than(1)
  assert_equal ['1'], @cw.words
end
test_no_longer_than_2() click to toggle source
# File test/test_filtering.rb, line 248
def test_no_longer_than_2
  @cw.words = ['1', '12', '123']
  @cw.no_longer_than(2)
  assert_equal ['1', '12'], @cw.words
end
test_no_longer_than_with_no_match() click to toggle source
# File test/test_filtering.rb, line 254
def test_no_longer_than_with_no_match
  @cw.words = ['123', '1234', '12345']
  @cw.no_longer_than(2)
  assert_equal [], @cw.words
end
test_no_shorter_than_1() click to toggle source
# File test/test_filtering.rb, line 290
def test_no_shorter_than_1
  @cw.words = ['1', '12', '123']
  @cw.no_shorter_than(1)
  assert_equal ['1', '12', '123'], @cw.words
end
test_no_shorter_than_2() click to toggle source
# File test/test_filtering.rb, line 296
def test_no_shorter_than_2
  @cw.words = ['1', '12', '123']
  @cw.no_shorter_than(2)
  assert_equal ['12', '123'], @cw.words
end
test_no_shorter_than_3() click to toggle source
# File test/test_filtering.rb, line 302
def test_no_shorter_than_3
  @cw.words = ['1', '12', '123']
  @cw.no_shorter_than(3)
  assert_equal ['123'], @cw.words
end
test_no_shorter_than_with_no_match() click to toggle source
# File test/test_filtering.rb, line 308
def test_no_shorter_than_with_no_match
  @cw.words = ['123', '1234', '12345']
  @cw.no_shorter_than(4)
  assert_equal ['1234', '12345'], @cw.words
end
test_repeat_none() click to toggle source
# File test/test_filtering.rb, line 367
def test_repeat_none
  @cw.words = ['1', '12', '123']
  @cw.repeat 0
  assert_equal ['1', '12', '123'], @cw.words
end
test_repeat_once() click to toggle source
# File test/test_filtering.rb, line 356
def test_repeat_once
  @cw.words = ['1', '12', '123']
  @cw.repeat 1
  assert_equal ['1', '12', '123', '1', '12', '123'], @cw.words
end
test_repeat_twice() click to toggle source
# File test/test_filtering.rb, line 362
def test_repeat_twice
  @cw.words = ['1', '12', '123']
  @cw.repeat 2
  assert_equal ['1', '12', '123', '1', '12', '123', '1', '12', '123'], @cw.words
end
test_something() click to toggle source
# File test/test_filtering.rb, line 22
def test_something
  assert true
end
test_word_length_1() click to toggle source
# File test/test_filtering.rb, line 409
def test_word_length_1
  @cw.words = ['1', '12', '123']
  @cw.word_length 1
  assert_equal ['1'], @cw.words
end
test_word_length_2() click to toggle source
# File test/test_filtering.rb, line 415
def test_word_length_2
  @cw.words = ['1', '12', '23', '123']
  @cw.word_length 2
  assert_equal ['12','23'], @cw.words
end
test_word_length_3() click to toggle source
# File test/test_filtering.rb, line 421
def test_word_length_3
  @cw.words = ['1', '12', '23', '123']
  @cw.word_length 3
  assert_equal ['123'], @cw.words
end
test_word_size_1() click to toggle source
# File test/test_filtering.rb, line 373
def test_word_size_1
  @cw.words = ['1', '12', '123']
  @cw.word_size 1
  assert_equal ['1'], @cw.words
end
test_word_size_2() click to toggle source
# File test/test_filtering.rb, line 379
def test_word_size_2
  @cw.words = ['1', '12', '23', '123']
  @cw.word_size 2
  assert_equal ['12','23'], @cw.words
end
test_word_size_3() click to toggle source
# File test/test_filtering.rb, line 385
def test_word_size_3
  @cw.words = ['1', '12', '23', '123']
  @cw.word_size 3
  assert_equal ['123'], @cw.words
end
test_words_beginning_with_a() click to toggle source
# File test/test_filtering.rb, line 62
def test_words_beginning_with_a
  @cw.words = ['able', 'zero']
  @cw.words_beginning_with('a')
  assert_equal ['able'], @cw.words
end
test_words_beginning_with_ab() click to toggle source
# File test/test_filtering.rb, line 74
def test_words_beginning_with_ab
  @cw.words = ['ardvark', 'able', 'zero']
  @cw.words_beginning_with('ab')
  assert_equal ['able'], @cw.words
end
test_words_beginning_with_range() click to toggle source
# File test/test_filtering.rb, line 80
def test_words_beginning_with_range
  @cw.words = ['able', 'delta', 'zero']
  @cw.words_beginning_with('a'..'d')
  assert_equal ['able', 'delta'], @cw.words
end
test_words_beginning_with_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 92
def test_words_beginning_with_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.words_beginning_with('')
  assert_equal ['able', 'zero'], @cw.words
end
test_words_beginning_with_with_no_match() click to toggle source
# File test/test_filtering.rb, line 86
def test_words_beginning_with_with_no_match
  @cw.words = ['able', 'zero']
  @cw.words_beginning_with('b')
  assert_equal [], @cw.words
end
test_words_beginning_with_z() click to toggle source
# File test/test_filtering.rb, line 68
def test_words_beginning_with_z
  @cw.words = ['able', 'zero']
  @cw.words_beginning_with('z')
  assert_equal ['zero'], @cw.words
end
test_words_ending_with_a() click to toggle source
# File test/test_filtering.rb, line 134
def test_words_ending_with_a
  @cw.words = ['else', 'antenna', 'alba', 'zero']
  @cw.words_ending_with('a')
  assert_equal ['antenna', 'alba'], @cw.words
end
test_words_ending_with_range() click to toggle source
# File test/test_filtering.rb, line 152
def test_words_ending_with_range
  @cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
  @cw.words_ending_with('y'..'z')
  assert_equal ['may', 'kay', 'pizazz'], @cw.words
end
test_words_ending_with_tion() click to toggle source
# File test/test_filtering.rb, line 146
def test_words_ending_with_tion
  @cw.words = ['tiona', 'lion', 'station', 'creation']
  @cw.words_ending_with('tion')
  assert_equal ['station', 'creation'], @cw.words
end
test_words_ending_with_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 164
def test_words_ending_with_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.words_ending_with('')
  assert_equal ['able', 'zero'], @cw.words
end
test_words_ending_with_with_no_match() click to toggle source
# File test/test_filtering.rb, line 158
def test_words_ending_with_with_no_match
  @cw.words = ['able', 'zero']
  @cw.words_ending_with('b')
  assert_equal [], @cw.words
end
test_words_ending_with_z() click to toggle source
# File test/test_filtering.rb, line 140
def test_words_ending_with_z
  @cw.words = ['joy', 'pazazz']
  @cw.words_ending_with('z')
  assert_equal ['pazazz'], @cw.words
end
test_words_including_a() click to toggle source
# File test/test_filtering.rb, line 206
def test_words_including_a
  @cw.words = ['else', 'banter', 'alt', 'zero']
  @cw.words_including('a')
  assert_equal ['banter', 'alt'], @cw.words
end
test_words_including_range() click to toggle source
# File test/test_filtering.rb, line 224
def test_words_including_range
  @cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
  @cw.words_including('g'..'k')
  assert_equal ['pizazz', 'kay'], @cw.words
end
test_words_including_tion() click to toggle source
# File test/test_filtering.rb, line 218
def test_words_including_tion
  @cw.words = ['tiona', 'lion', 'station', 'creation']
  @cw.words_including('tion')
  assert_equal ['tiona', 'station', 'creation'], @cw.words
end
test_words_including_with_empty_string_returns_all() click to toggle source
# File test/test_filtering.rb, line 236
def test_words_including_with_empty_string_returns_all
  @cw.words = ['able', 'zero']
  @cw.words_including('')
  assert_equal ['able', 'zero'], @cw.words
end
test_words_including_with_no_match() click to toggle source
# File test/test_filtering.rb, line 230
def test_words_including_with_no_match
  @cw.words = ['able', 'zero']
  @cw.words_including('c')
  assert_equal [], @cw.words
end
test_words_including_z() click to toggle source
# File test/test_filtering.rb, line 212
def test_words_including_z
  @cw.words = ['joy', 'amaze', '123']
  @cw.words_including('z')
  assert_equal ['amaze'], @cw.words
end
test_words_no_longer_than_0() click to toggle source
# File test/test_filtering.rb, line 260
def test_words_no_longer_than_0
  @cw.words = ['1', '12', '123']
  @cw.words_no_longer_than(0)
  assert_equal [], @cw.words
end
test_words_no_longer_than_1() click to toggle source
# File test/test_filtering.rb, line 266
def test_words_no_longer_than_1
  @cw.words = ['1', '12', '123']
  @cw.words_no_longer_than(1)
  assert_equal ['1'], @cw.words
end
test_words_no_longer_than_2() click to toggle source
# File test/test_filtering.rb, line 272
def test_words_no_longer_than_2
  @cw.words = ['1', '12', '123']
  @cw.words_no_longer_than(2)
  assert_equal ['1', '12'], @cw.words
end
test_words_no_longer_than_with_words_no_match() click to toggle source
# File test/test_filtering.rb, line 278
def test_words_no_longer_than_with_words_no_match
  @cw.words = ['123', '1234', '12345']
  @cw.words_no_longer_than(2)
  assert_equal [], @cw.words
end
test_words_no_shorter_than_0() click to toggle source
# File test/test_filtering.rb, line 314
def test_words_no_shorter_than_0
  @cw.words = ['1', '12', '123']
  @cw.words_no_shorter_than(0)
  assert_equal ['1', '12', '123'], @cw.words
end
test_words_no_shorter_than_1() click to toggle source
# File test/test_filtering.rb, line 320
def test_words_no_shorter_than_1
  @cw.words = ['1', '12', '123']
  @cw.words_no_shorter_than(1)
  assert_equal ['1', '12', '123'], @cw.words
end
test_words_no_shorter_than_2() click to toggle source
# File test/test_filtering.rb, line 326
def test_words_no_shorter_than_2
  @cw.words = ['1', '12', '123']
  @cw.words_no_shorter_than(2)
  assert_equal ['12', '123'], @cw.words
end
test_words_no_shorter_than_3() click to toggle source
# File test/test_filtering.rb, line 332
def test_words_no_shorter_than_3
  @cw.words = ['1', '12', '123']
  @cw.words_no_shorter_than(3)
  assert_equal ['123'], @cw.words
end
test_words_no_shorter_than_with_words_no_match() click to toggle source
# File test/test_filtering.rb, line 338
def test_words_no_shorter_than_with_words_no_match
  @cw.words = ['123', '1234', '12345']
  @cw.words_no_shorter_than(4)
  assert_equal ['1234', '12345'], @cw.words
end