(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestStringIndexPrefixFilterRuneError(t *testing.T) { |
| 87 | filter := stringIndexPrefixFilter("�abc", false, 4) |
| 88 | if filter == nil { |
| 89 | t.Fatal("expected a filter for valid UTF-8") |
| 90 | } |
| 91 | for _, tc := range []struct { |
| 92 | input string |
| 93 | index int |
| 94 | ok bool |
| 95 | }{ |
| 96 | {"xx�abc", 2, true}, |
| 97 | {"xxxxx", 0, false}, |
| 98 | {"x\xffabc�abc", 0, true}, // invalid input must reach the rune engine |
| 99 | } { |
| 100 | index, ok := filter(tc.input, 0) |
| 101 | if index != tc.index || ok != tc.ok { |
| 102 | t.Fatalf("filter(%q) = %d, %v; want %d, %v", tc.input, index, ok, tc.index, tc.ok) |
| 103 | } |
| 104 | } |
| 105 | m, err := MustCompile("�abc").FindStringMatch("x\xffabc�abc") |
| 106 | if err != nil || m == nil || m.RuneIndex != 1 { |
| 107 | t.Fatalf("expected the invalid-byte match before the valid U+FFFD: %v, %v", m, err) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func TestStringIndexPrefixFilterASCIIIgnoreCase(t *testing.T) { |
| 112 | filter := stringIndexPrefixFilter("abc", true, 3) |
nothing calls this directly
no test coverage detected