MCPcopy Create free account
hub / github.com/dlclark/regexp2 / TestStringFixedDistanceStringFilter

Function TestStringFixedDistanceStringFilter

stringprefixfilter_test.go:214–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestStringFixedDistanceStringFilter(t *testing.T) {
215 filter := stringFixedDistanceStringFilter("abc", 2, 3)
216 if filter == nil {
217 t.Fatal("expected filter")
218 }
219
220 candidateByteIndex, ok := filter("é12abc", 0)
221 if !ok {
222 t.Fatal("expected candidate")
223 }
224 if got, want := candidateByteIndex, 2; got != want {
225 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
226 }
227
228 if _, ok := filter("é12ab", 0); ok {
229 t.Fatal("unexpected candidate for missing literal")
230 }
231}
232
233func TestStringFixedDistanceStringFilterLongLiteral(t *testing.T) {
234 if filter := stringFixedDistanceStringFilter("aaaaaaaaa", 0, 9); filter != nil {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected