When the table of 8-bit shifts overflows.
(self)
| 431 | self.checkequal(1, haystack + needle, 'count', needle) |
| 432 | |
| 433 | def test_find_shift_table_overflow(self): |
| 434 | """When the table of 8-bit shifts overflows.""" |
| 435 | N = 2**8 + 100 |
| 436 | |
| 437 | # first check the periodic case |
| 438 | # here, the shift for 'b' is N + 1. |
| 439 | pattern1 = 'a' * N + 'b' + 'a' * N |
| 440 | text1 = 'babbaa' * N + pattern1 |
| 441 | self.checkequal(len(text1)-len(pattern1), |
| 442 | text1, 'find', pattern1) |
| 443 | |
| 444 | # now check the non-periodic case |
| 445 | # here, the shift for 'd' is 3*(N+1)+1 |
| 446 | pattern2 = 'ddd' + 'abc' * N + "eee" |
| 447 | text2 = pattern2[:-1] + "ddeede" * 2 * N + pattern2 + "de" * N |
| 448 | self.checkequal(len(text2) - N*len("de") - len(pattern2), |
| 449 | text2, 'find', pattern2) |
| 450 | |
| 451 | def test_lower(self): |
| 452 | self.checkequal('hello', 'HeLLo', 'lower') |
nothing calls this directly
no test coverage detected