MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_adaptive_find

Method test_adaptive_find

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

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

checkequalMethod · 0.95
lenFunction · 0.85

Tested by

no test coverage detected