(t *testing.T)
| 291 | } |
| 292 | |
| 293 | func TestFindStringPrefixCandidateFallbacks(t *testing.T) { |
| 294 | re := &Regexp{ |
| 295 | stringPrefixFilter: func(input string, startAt int) (candidateByteIndex int, ok bool) { |
| 296 | return 1, true |
| 297 | }, |
| 298 | } |
| 299 | |
| 300 | candidateByteIndex, ok := re.findStringPrefixCandidate("éabc", 0) |
| 301 | if !ok { |
| 302 | t.Fatal("expected fallback candidate") |
| 303 | } |
| 304 | if got, want := candidateByteIndex, 0; got != want { |
| 305 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 306 | } |
| 307 | |
| 308 | re.stringPrefixFilter = func(input string, startAt int) (candidateByteIndex int, ok bool) { |
| 309 | return startAt - 1, true |
| 310 | } |
| 311 | candidateByteIndex, ok = re.findStringPrefixCandidate("abc", 1) |
| 312 | if !ok { |
| 313 | t.Fatal("expected fallback candidate") |
| 314 | } |
| 315 | if got, want := candidateByteIndex, 1; got != want { |
| 316 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | func TestFindStringPrefixCandidateDisabledForRightToLeft(t *testing.T) { |
| 321 | re := &Regexp{ |
nothing calls this directly
no test coverage detected