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

Function TestStringIndexPrefixFilter

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

Source from the content-addressed store, hash-verified

9)
10
11func TestStringIndexPrefixFilter(t *testing.T) {
12 filter := stringIndexPrefixFilter("abc", false, 3)
13 if filter == nil {
14 t.Fatal("expected filter")
15 }
16
17 candidateByteIndex, ok := filter("xxabc", 0)
18 if !ok {
19 t.Fatal("expected candidate")
20 }
21 if got, want := candidateByteIndex, 2; got != want {
22 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
23 }
24
25 candidateByteIndex, ok = filter("xxabcabc", 3)
26 if !ok {
27 t.Fatal("expected candidate after startAt")
28 }
29 if got, want := candidateByteIndex, 5; got != want {
30 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
31 }
32
33 if _, ok := filter("xxab", 0); ok {
34 t.Fatal("unexpected candidate for missing prefix")
35 }
36}
37
38func TestStringFilterInvalidUTF8Regression(t *testing.T) {
39 for _, pattern := range []string{`�abc`, `(?:�abc|xyz)`, `.�ab`, `[x]*�abc`} {

Callers

nothing calls this directly

Calls 1

stringIndexPrefixFilterFunction · 0.85

Tested by

no test coverage detected