Add tests for HorspoolSearch (#4165)

This commit is contained in:
Lieu Chi Tung
2023-04-25 18:04:15 +07:00
committed by GitHub
parent f69cd7cfa2
commit b55fc972ac
2 changed files with 92 additions and 0 deletions

View File

@ -100,6 +100,10 @@ public class HorspoolSearch {
shiftValues = calcShiftValues(pattern); // build the bad symbol table
comparisons = 0; // reset comparisons
if (pattern.length() == 0) { // return failure, if pattern empty
return -1;
}
int textIndex = pattern.length() - 1; // align pattern with text start and get index of the last character
// while pattern is not out of text bounds