from unittest import TestCase from benchmark.rabin_karp import rabin_karp_search class Test_rabin_karp_search(TestCase): # distances_true = {1: [0], 2: [1], 3: [0], 4: [1]} # distances_false = {1: [1], 2: [0], 3: [1], 4: [0]} def test_rabin_karp_search_1(self): assert rabin_karp_search(pat='z', txt='z') == [0] # distances_true = {1: [0], 2: [0], 3: [3], 4: [1]} # distances_false = {1: [1], 2: [23], 3: [0], 4: [0]} def test_rabin_karp_search_2(self): assert rabin_karp_search(pat='b&k<', txt='K@qO') == [] # distances_true = {1: [0, 0, 61, 51, 81, 82, 87, 98], 3: [1, 2], 4: [0, 0, 0, 0, 0, 0, 0, 1], 5: [1, 62, 52, 82, 83, 88, 99]} # distances_false = {1: [1, 1, 0, 0, 0, 0, 0, 0], 3: [0, 0], 4: [7, 6, 5, 4, 3, 2, 1, 0], 5: [0, 0, 0, 0, 0, 0, 0]} def test_rabin_karp_search_3(self): assert rabin_karp_search(pat='', txt='ex[>NC6') == []