>>> test_rabin_karp() Success.
()
| 52 | |
| 53 | |
| 54 | def test_rabin_karp() -> None: |
| 55 | """ |
| 56 | >>> test_rabin_karp() |
| 57 | Success. |
| 58 | """ |
| 59 | # Test 1) |
| 60 | pattern = "abc1abc12" |
| 61 | text1 = "alskfjaldsabc1abc1abc12k23adsfabcabc" |
| 62 | text2 = "alskfjaldsk23adsfabcabc" |
| 63 | assert rabin_karp(pattern, text1) |
| 64 | assert not rabin_karp(pattern, text2) |
| 65 | |
| 66 | # Test 2) |
| 67 | pattern = "ABABX" |
| 68 | text = "ABABZABABYABABX" |
| 69 | assert rabin_karp(pattern, text) |
| 70 | |
| 71 | # Test 3) |
| 72 | pattern = "AAAB" |
| 73 | text = "ABAAAAAB" |
| 74 | assert rabin_karp(pattern, text) |
| 75 | |
| 76 | # Test 4) |
| 77 | pattern = "abcdabcy" |
| 78 | text = "abcxabcdabxabcdabcdabcy" |
| 79 | assert rabin_karp(pattern, text) |
| 80 | |
| 81 | # Test 5) |
| 82 | pattern = "Lü" |
| 83 | text = "Lüsai" |
| 84 | assert rabin_karp(pattern, text) |
| 85 | pattern = "Lue" |
| 86 | assert not rabin_karp(pattern, text) |
| 87 | print("Success.") |
| 88 | |
| 89 | |
| 90 | if __name__ == "__main__": |
no test coverage detected