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

Method test_find_many_lengths

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

Source from the content-addressed store, hash-verified

350 check_pattern(lambda *args: 0)
351
352 def test_find_many_lengths(self):
353 haystack_repeats = [a * 10**e for e in range(6) for a in (1,2,5)]
354 haystacks = [(n, self.fixtype("abcab"*n + "da")) for n in haystack_repeats]
355
356 needle_repeats = [a * 10**e for e in range(6) for a in (1, 3)]
357 needles = [(m, self.fixtype("abcab"*m + "da")) for m in needle_repeats]
358
359 for n, haystack1 in haystacks:
360 haystack2 = haystack1[:-1]
361 for m, needle in needles:
362 answer1 = 5 * (n - m) if m <= n else -1
363 self.assertEqual(haystack1.find(needle), answer1, msg=(n,m))
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,

Callers

nothing calls this directly

Calls 3

fixtypeMethod · 0.95
assertEqualMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected