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

Function TestStringFixedDistanceCharFilter

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

Source from the content-addressed store, hash-verified

178}
179
180func TestStringFixedDistanceCharFilter(t *testing.T) {
181 filter := stringFixedDistanceCharFilter('a', 2, 3)
182 if filter == nil {
183 t.Fatal("expected filter")
184 }
185
186 candidateByteIndex, ok := filter("é12a", 0)
187 if !ok {
188 t.Fatal("expected candidate")
189 }
190 if got, want := candidateByteIndex, 2; got != want {
191 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
192 }
193
194 if _, ok := filter("xyz", 0); ok {
195 t.Fatal("unexpected candidate for missing char")
196 }
197
198 if _, ok := filter("xyz", 0); ok {
199 t.Fatal("unexpected candidate for missing char")
200 }
201}
202
203func TestStringFixedDistanceCharFilterCandidateBeforeStart(t *testing.T) {
204 filter := stringFixedDistanceCharFilter('a', 2, 1)

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected