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

Function TestStringFixedDistanceStringFilter

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

Source from the content-addressed store, hash-verified

153}
154
155func TestStringFixedDistanceStringFilter(t *testing.T) {
156 filter := stringFixedDistanceStringFilter("abc", 2, 3)
157 if filter == nil {
158 t.Fatal("expected filter")
159 }
160
161 candidateByteIndex, ok := filter("é12abc", 0)
162 if !ok {
163 t.Fatal("expected candidate")
164 }
165 if got, want := candidateByteIndex, 2; got != want {
166 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
167 }
168
169 if _, ok := filter("é12ab", 0); ok {
170 t.Fatal("unexpected candidate for missing literal")
171 }
172}
173
174func TestStringFixedDistanceStringFilterLongLiteral(t *testing.T) {
175 if filter := stringFixedDistanceStringFilter("aaaaaaaaa", 0, 9); filter != nil {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected