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

Function TestStringIndexPrefixFilter

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

stringIndexPrefixFilterFunction · 0.85

Tested by

no test coverage detected