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

Function TestStringFixedDistanceSetFilter

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

Source from the content-addressed store, hash-verified

289}
290
291func TestStringFixedDistanceSetFilter(t *testing.T) {
292 filter := stringFixedDistanceSetFilter(syntax.FixedDistanceSet{
293 Range: &syntax.SingleRange{First: 'a', Last: 'c'},
294 Distance: 2,
295 }, 3)
296 if filter == nil {
297 t.Fatal("expected filter")
298 }
299
300 candidateByteIndex, ok := filter("é12b", 0)
301 if !ok {
302 t.Fatal("expected candidate")
303 }
304 if got, want := candidateByteIndex, 2; got != want {
305 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
306 }
307 if _, ok := filter("é12z", 0); ok {
308 t.Fatal("unexpected candidate")
309 }
310}
311
312func TestStringFixedDistanceSetFilterSmallSet(t *testing.T) {
313 filter := stringFixedDistanceSetFilter(syntax.FixedDistanceSet{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected