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

Function TestStringFixedDistanceCharFilter

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

Source from the content-addressed store, hash-verified

119}
120
121func TestStringFixedDistanceCharFilter(t *testing.T) {
122 filter := stringFixedDistanceCharFilter('a', 2, 3)
123 if filter == nil {
124 t.Fatal("expected filter")
125 }
126
127 candidateByteIndex, ok := filter("é12a", 0)
128 if !ok {
129 t.Fatal("expected candidate")
130 }
131 if got, want := candidateByteIndex, 2; got != want {
132 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
133 }
134
135 if _, ok := filter("xyz", 0); ok {
136 t.Fatal("unexpected candidate for missing char")
137 }
138
139 if _, ok := filter("xyz", 0); ok {
140 t.Fatal("unexpected candidate for missing char")
141 }
142}
143
144func TestStringFixedDistanceCharFilterCandidateBeforeStart(t *testing.T) {
145 filter := stringFixedDistanceCharFilter('a', 2, 1)

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected