This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
kse-02/tests/test_rabin_karp.py

20 lines
912 B
Python
Raw Normal View History

2023-12-09 19:52:07 +00:00
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]}
2023-12-09 19:52:07 +00:00
def test_rabin_karp_search_1(self):
assert rabin_karp_search(pat='z', txt='z') == [0]
2023-12-09 19:52:07 +00:00
# distances_true = {1: [0], 2: [0], 3: [3], 4: [1]}
# distances_false = {1: [1], 2: [23], 3: [0], 4: [0]}
2023-12-09 19:52:07 +00:00
def test_rabin_karp_search_2(self):
assert rabin_karp_search(pat='b&k<', txt='K@qO') == []
2023-12-09 19:52:07 +00:00
# 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]}
2023-12-09 19:52:07 +00:00
def test_rabin_karp_search_3(self):
assert rabin_karp_search(pat='', txt='ex[>NC6') == []