MCPcopy Index your code
hub / github.com/python/cpython / test_adaptive_find

Method test_adaptive_find

Lib/test/string_tests.py:411–421  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 1

checkequalMethod · 0.95

Tested by

no test coverage detected