Exemple #1
0
 def test_search(self):
     hash_methods = [Linear, Quad, RabinKarph]
     for test_name, text, pattern, expected in get_tests():
         for hash_method in hash_methods:
             with self.subTest(f'{hash_method.__name__} {test_name}'):
                 actual = Hash(pattern, hash_method).search(text)
                 msg = f'\nTEXT: {text} :TEXT\nSUB: {pattern} :SUB'
                 self.assertListEqual(expected, actual.found_indexes, msg)
Exemple #2
0
 def test_search(self):
     for test_name, text, pattern, expected in get_tests():
         with self.subTest(f'{test_name}'):
             actual = Automate(pattern).search(text)
             msg = f'\nTEXT: {text} :TEXT\nSUB: {pattern} :SUB'
             self.assertListEqual(expected, actual.found_indexes, msg)