Skip to content

Commit ae1530b

Browse files
committed
test: add doctest exercising multi-position bad-character shift
Addresses reviewer feedback by adding a test case where the pattern 'MNOP' is searched in a 32-character text, verifying correct match positions [12, 28] and demonstrating that the bad-character shift skips multiple positions at once.
1 parent b55d94a commit ae1530b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

strings/boyer_moore_search.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ def bad_character_heuristic(self) -> list[int]:
116116
>>> bms = BoyerMooreSearch(text="ABAABA", pattern="AB")
117117
>>> bms.bad_character_heuristic()
118118
[0, 3]
119+
120+
Example where the bad-character shift skips multiple positions at once:
121+
122+
>>> bms = BoyerMooreSearch(
123+
... text="ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP", pattern="MNOP"
124+
... )
125+
>>> bms.bad_character_heuristic()
126+
[12, 28]
119127
"""
120128

121129
positions = []

0 commit comments

Comments
 (0)