(self)
| 409 | self.assertEqual(haystack2.find(needle), -1, msg=(n,m)) |
| 410 | |
| 411 | def test_adaptive_find(self): |
| 412 | # This would be very slow for the naive algorithm, |
| 413 | # but str.find() should be O(n + m). |
| 414 | for N in 1000, 10_000, 100_000, 1_000_000: |
| 415 | A, B = 'a' * N, 'b' * N |
| 416 | haystack = A + A + B + A + A |
| 417 | needle = A + B + B + A |
| 418 | self.checkequal(-1, haystack, 'find', needle) |
| 419 | self.checkequal(0, haystack, 'count', needle) |
| 420 | self.checkequal(len(haystack), haystack + needle, 'find', needle) |
| 421 | self.checkequal(1, haystack + needle, 'count', needle) |
| 422 | |
| 423 | def test_find_with_memory(self): |
| 424 | # Test the "Skip with memory" path in the two-way algorithm. |
nothing calls this directly
no test coverage detected