Commit 537aaa9
committed
test: add doctest that would infinite-loop with naive shift fix
Addresses reviewer feedback by adding a test case where the mismatched
character ('C') appears to the RIGHT of the mismatch offset in the
pattern 'ABCB'. A naive shift that searches the entire pattern would
compute a negative shift and loop forever; the correct implementation
only searches to the left of the mismatch offset, guaranteeing shift>=1.
If the shift logic regresses, this doctest will hang instead of passing.1 parent b55d94a commit 537aaa9
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| |||
0 commit comments