Exemplo n.º 1
0
    def test_same_word_isnt_anagram(self):
        self.assertEqual(
            [],
            detect_anagrams('banana', ['banana'])
        )

        self.assertEqual(
            [],
            detect_anagrams('go', 'go Go GO'.split())
        )
Exemplo n.º 2
0
 def test_detects_three_anagrams(self):
     candidates = [
         "gallery", "ballerina", "regally", "clergy", "largely", "leading"
     ]
     self.assertEqual(
         detect_anagrams("allergy", candidates),
         ["gallery", "regally", "largely"])
Exemplo n.º 3
0
 def test_detects_three_anagrams(self):
     candidates = [
         "gallery", "ballerina", "regally", "clergy", "largely", "leading"
     ]
     self.assertEqual(
         detect_anagrams("allergy", candidates),
         ["gallery", "regally", "largely"])
Exemplo n.º 4
0
 def test_multiple_anagrams(self):
     self.assertEqual(
         'gallery regally largely'.split(),
         detect_anagrams(
             'allergy',
             'gallery ballerina regally clergy largely leading'.split()
         )
     )
Exemplo n.º 5
0
 def test_does_not_detect_anagram_subsets(self):
     self.assertEqual(detect_anagrams("good", ["dog", "goody"]), [])
Exemplo n.º 6
0
 def test_eliminate_anagram_subsets(self):
     self.assertEqual([], detect_anagrams('good', 'dog goody'.split()))
Exemplo n.º 7
0
 def test_detect_multiple_anagrams(self):
     self.assertEqual(['stream', 'maters'],
                      detect_anagrams('master',
                                      'stream pigeon maters'.split()))
Exemplo n.º 8
0
 def test_multiple_anagrams(self):
     self.assertEqual(
         'gallery regally largely'.split(),
         detect_anagrams(
             'allergy',
             'gallery ballerina regally clergy largely leading'.split()))
Exemplo n.º 9
0
 def test_does_not_confuse_different_duplicates(self):
     self.assertEqual([], detect_anagrams('galea', ['eagle']))
Exemplo n.º 10
0
 def test_eliminate_anagram_subsets(self):
     self.assertEqual([],
         detect_anagrams('good', 'dog goody'.split()))
Exemplo n.º 11
0
 def test_detects_two_anagrams(self):
     candidates = ["stream", "pigeon", "maters"]
     self.assertEqual(
         detect_anagrams("master", candidates), ["stream", "maters"])
Exemplo n.º 12
0
 def test_capital_word_is_not_own_anagram(self):
     self.assertEqual(detect_anagrams("BANANA", ["Banana"]), [])
Exemplo n.º 13
0
 def test_detects_simple_anagram(self):
     candidates = ["tan", "stand", "at"]
     self.assertEqual(detect_anagrams("ant", candidates), ["tan"])
Exemplo n.º 14
0
 def test_does_not_detect_false_positives(self):
     self.assertEqual(detect_anagrams("galea", ["eagle"]), [])
Exemplo n.º 15
0
 def test_no_matches(self):
     self.assertEqual([],
                      detect_anagrams('diaper',
                                      'hello world zombies pants'.split()))
Exemplo n.º 16
0
    def test_same_word_isnt_anagram(self):
        self.assertEqual([], detect_anagrams('banana', ['banana']))

        self.assertEqual([], detect_anagrams('go', 'go Go GO'.split()))
Exemplo n.º 17
0
 def test_anagrams_are_case_insensitive(self):
     self.assertEqual(['Carthorse'],
                      detect_anagrams(
                          'Orchestra',
                          'cashregister Carthorse radishes'.split()))
Exemplo n.º 18
0
 def test_detects_anagrams_using_case_insensitive_subject(self):
     candidates = ["cashregister", "carthorse", "radishes"]
     self.assertEqual(
         detect_anagrams("Orchestra", candidates), ["carthorse"])
Exemplo n.º 19
0
 def test_does_not_detect_anagram_subsets(self):
     self.assertEqual(detect_anagrams("good", ["dog", "goody"]), [])
Exemplo n.º 20
0
 def test_does_not_detect_a_anagram_if_the_original_word_is_repeated(self):
     self.assertEqual(detect_anagrams("go", ["go Go GO"]), [])
Exemplo n.º 21
0
 def test_detects_anagram(self):
     candidates = ["enlists", "google", "inlets", "banana"]
     self.assertEqual(detect_anagrams("listen", candidates), ["inlets"])
Exemplo n.º 22
0
 def test_no_matches(self):
     candidates = ["hello", "world", "zombies", "pants"]
     self.assertEqual(detect_anagrams("diaper", candidates), [])
Exemplo n.º 23
0
 def test_no_matches(self):
   self.assertEqual(
     [],
     detect_anagrams(u'diaper', [u'hello', u'world', u'zombies', u'pants'])
   )
Exemplo n.º 24
0
 def test_detect_multiple_anagrams(self):
     self.assertEqual(['stream', 'maters'],
         detect_anagrams('master', 'stream pigeon maters'.split()))
Exemplo n.º 25
0
 def test_does_not_detect_false_positives(self):
     self.assertEqual(detect_anagrams("galea", ["eagle"]), [])
Exemplo n.º 26
0
 def test_anagrams_are_case_insensitive(self):
     self.assertEqual(['Carthorse'],
         detect_anagrams('Orchestra','cashregister Carthorse radishes'.split()))
Exemplo n.º 27
0
 def test_does_not_detect_a_word_as_its_own_anagram(self):
     self.assertEqual(detect_anagrams("banana", ["Banana"]), [])
Exemplo n.º 28
0
 def test_is_case_insensitive(self):
   self.assertEqual(
     [u'Orchestra'],
     detect_anagrams(u'Orchestra', [u'cashregister', u'Carthorse', u'radishes'])
   )
Exemplo n.º 29
0
 def test_detect_anagram(self):
     self.assertEqual(['inlets'],
                      detect_anagrams(
                          'listen', 'enlists google inlets banana'.split()))
Exemplo n.º 30
0
 def test_detects_simple_anagram(self):
     candidates = ["tan", "stand", "at"]
     self.assertEqual(detect_anagrams("ant", candidates), ["tan"])
Exemplo n.º 31
0
 def test_does_not_detect_identical_words(self):
     candidates = ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]
     self.assertEqual(detect_anagrams("corn", candidates), ["cron"])
Exemplo n.º 32
0
 def test_does_not_detect_identical_words(self):
     candidates = ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]
     self.assertEqual(detect_anagrams("corn", candidates), ["cron"])
Exemplo n.º 33
0
 def test_does_not_detect_non_anagrams_with_identical_checksum(self):
     self.assertEqual(detect_anagrams("mass", ["last"]), [])
Exemplo n.º 34
0
 def test_detects_two_anagrams(self):
     candidates = ["stream", "pigeon", "maters"]
     self.assertEqual(
         detect_anagrams("master", candidates), ["stream", "maters"])
Exemplo n.º 35
0
 def test_detects_anagrams_using_case_insensitive_subjec(self):
     candidates = ["cashregister", "carthorse", "radishes"]
     self.assertEqual(
         detect_anagrams("Orchestra", candidates), ["carthorse"])
Exemplo n.º 36
0
 def test_detects_anagram(self):
     candidates = ["enlists", "google", "inlets", "banana"]
     self.assertEqual(detect_anagrams("listen", candidates), ["inlets"])
Exemplo n.º 37
0
 def test_detects_anagrams_using_case_insensitive_possible_matches(self):
     candidates = ["cashregister", "Carthorse", "radishes"]
     self.assertEqual(
         detect_anagrams("orchestra", candidates), ["Carthorse"])
Exemplo n.º 38
0
 def test_does_not_detect_non_anagrams_with_identical_checksum(self):
     self.assertEqual(detect_anagrams("mass", ["last"]), [])
Exemplo n.º 39
0
 def test_does_not_detect_a_word_as_its_own_anagram(self):
     self.assertEqual(detect_anagrams("banana", ["Banana"]), [])
Exemplo n.º 40
0
 def test_detects_anagrams_using_case_insensitive_possible_matches(self):
     candidates = ["cashregister", "Carthorse", "radishes"]
     self.assertEqual(
         detect_anagrams("orchestra", candidates), ["Carthorse"])
Exemplo n.º 41
0
 def test_does_not_detect_a_anagram_if_the_original_word_is_repeated(self):
     self.assertEqual(detect_anagrams("go", ["go Go GO"]), [])
Exemplo n.º 42
0
 def test_anagrams_must_use_all_letters_exactly_once(self):
     self.assertEqual(detect_anagrams("tapper", ["patter"]), [])
Exemplo n.º 43
0
 def test_anagrams_must_use_all_letters_exactly_once(self):
     self.assertEqual(detect_anagrams("tapper", ["patter"]), [])
Exemplo n.º 44
0
 def test_speed(self):
     detect_anagrams(rand_letters(10), [ rand_letters(10) for _ in range(10**6)])
Exemplo n.º 45
0
 def test_capital_word_is_not_own_anagram(self):
     self.assertEqual(detect_anagrams("BANANA", ["Banana"]), [])
Exemplo n.º 46
0
 def test_no_matches(self):
     candidates = ["hello", "world", "zombies", "pants"]
     self.assertEqual(detect_anagrams("diaper", candidates), [])
Exemplo n.º 47
0
 def test_detects_simple_anagram(self):
   self.assertEqual(
     [u'tan'],
     detect_anagrams(u'ant', [u'tan', u'stand', u'at'])
   )
Exemplo n.º 48
0
 def test_detect_simple_anagram(self):
     self.assertEqual(['tan'],
         detect_anagrams('ant', 'tan stand at'.split()))
Exemplo n.º 49
0
 def test_eliminates_anagram_subsets(self):
   self.assertEqual(
     [],
     detect_anagrams(u'good', [u'dog', u'goody'])
   )
Exemplo n.º 50
0
 def test_does_not_confuse_different_duplicates(self):
     self.assertEqual([],
         detect_anagrams('galea', ['eagle']))
Exemplo n.º 51
0
 def test_detects_multiple_anagrams(self):
   self.assertEqual(
     [u'gallery', u'regally', u'largely'],
     detect_anagrams(u'allergy', [u'gallery', u'ballerina', u'regally', u'clergy', u'largely', u'leading'])
   )
Exemplo n.º 52
0
 def test_detect_anagram(self):
     self.assertEqual(['inlets'],
         detect_anagrams('listen', 'enlists google inlets banana'.split()))
Exemplo n.º 53
0
 def test_same_word_isnt_anagram(self):
   self.assertEqual(
     [],
     detect_anagrams(u'banana', [u'banana'])
   )
Exemplo n.º 54
0
 def test_no_matches(self):
     self.assertEqual([],
         detect_anagrams('diaper', 'hello world zombies pants'.split()))
Exemplo n.º 55
0
 def test_detect_simple_anagram(self):
     self.assertEqual(['tan'], detect_anagrams('ant',
                                               'tan stand at'.split()))