When the table of 8-bit shifts overflows.
(self)
| 386 | self.checkequal(1, haystack + needle, 'count', needle) |
| 387 | |
| 388 | def test_find_shift_table_overflow(self): |
| 389 | """When the table of 8-bit shifts overflows.""" |
| 390 | N = 2**8 + 100 |
| 391 | |
| 392 | # first check the periodic case |
| 393 | # here, the shift for 'b' is N + 1. |
| 394 | pattern1 = 'a' * N + 'b' + 'a' * N |
| 395 | text1 = 'babbaa' * N + pattern1 |
| 396 | self.checkequal(len(text1)-len(pattern1), |
| 397 | text1, 'find', pattern1) |
| 398 | |
| 399 | # now check the non-periodic case |
| 400 | # here, the shift for 'd' is 3*(N+1)+1 |
| 401 | pattern2 = 'ddd' + 'abc' * N + "eee" |
| 402 | text2 = pattern2[:-1] + "ddeede" * 2 * N + pattern2 + "de" * N |
| 403 | self.checkequal(len(text2) - N*len("de") - len(pattern2), |
| 404 | text2, 'find', pattern2) |
| 405 | |
| 406 | def test_lower(self): |
| 407 | self.checkequal('hello', 'HeLLo', 'lower') |
nothing calls this directly
no test coverage detected