Exemple #1
0
 def test_change_text(self):
     text = "aaaaaaaaa"
     pattern = "a"
     algorithm = BoyerMoore(self._get_heuristic(), pattern, text)
     res = algorithm.get_results()
     self.assertEqual(res, [0, 1, 2, 3, 4, 5, 6, 7, 8])
     text = "bbbbbbbbbbbbbbb"
     algorithm.set_text(text)
     res = algorithm.get_results()
     self.assertEqual(res, [])
Exemple #2
0
 def test_more_match(self):
     text = "asajakvhajsdajakvvajsdbajakvhasjd asajakvdbha sjasdjajakvasvbdjas"
     pattern = "ajakv"
     algorithm = BoyerMoore(self._get_heuristic(), pattern, text)
     res = algorithm.get_results()
     self.assertEqual(res, [2, 12, 23, 36, 52])
Exemple #3
0
 def test_single_letter(self):
     text = "aaaaaaaaa"
     pattern = "a"
     algorithm = BoyerMoore(self._get_heuristic(), pattern, text)
     res = algorithm.get_results()
     self.assertEqual(res, [0, 1, 2, 3, 4, 5, 6, 7, 8])
Exemple #4
0
 def test_find_no_match(self):
     text = "asdjasdvhajsdvajsdbhasjd asdbha sjasdjasvbdjas"
     pattern = "asff"
     algorithm = BoyerMoore(self._get_heuristic(), pattern, text)
     res = algorithm.get_results()
     self.assertEqual(res, [])