(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func 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 | |
| 37 | func TestStringIndexPrefixFilterMinRequiredLengthUsesBytes(t *testing.T) { |
| 38 | filter := stringIndexPrefixFilter("é", false, 2) |
nothing calls this directly
no test coverage detected