(self)
| 364 | self.assertEqual(haystack2.find(needle), -1, msg=(n,m)) |
| 365 | |
| 366 | def test_adaptive_find(self): |
| 367 | # This would be very slow for the naive algorithm, |
| 368 | # but str.find() should be O(n + m). |
| 369 | for N in 1000, 10_000, 100_000, 1_000_000: |
| 370 | A, B = 'a' * N, 'b' * N |
| 371 | haystack = A + A + B + A + A |
| 372 | needle = A + B + B + A |
| 373 | self.checkequal(-1, haystack, 'find', needle) |
| 374 | self.checkequal(0, haystack, 'count', needle) |
| 375 | self.checkequal(len(haystack), haystack + needle, 'find', needle) |
| 376 | self.checkequal(1, haystack + needle, 'count', needle) |
| 377 | |
| 378 | def test_find_with_memory(self): |
| 379 | # Test the "Skip with memory" path in the two-way algorithm. |
nothing calls this directly
no test coverage detected