(t *testing.T)
| 350 | } |
| 351 | |
| 352 | func TestFindStringPrefixCandidateFallbacks(t *testing.T) { |
| 353 | re := &Regexp{ |
| 354 | stringPrefixFilter: func(input string, startAt int) (candidateByteIndex int, ok bool) { |
| 355 | return 1, true |
| 356 | }, |
| 357 | } |
| 358 | |
| 359 | candidateByteIndex, ok := re.findStringPrefixCandidate("éabc", 0) |
| 360 | if !ok { |
| 361 | t.Fatal("expected fallback candidate") |
| 362 | } |
| 363 | if got, want := candidateByteIndex, 0; got != want { |
| 364 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 365 | } |
| 366 | |
| 367 | re.stringPrefixFilter = func(input string, startAt int) (candidateByteIndex int, ok bool) { |
| 368 | return startAt - 1, true |
| 369 | } |
| 370 | candidateByteIndex, ok = re.findStringPrefixCandidate("abc", 1) |
| 371 | if !ok { |
| 372 | t.Fatal("expected fallback candidate") |
| 373 | } |
| 374 | if got, want := candidateByteIndex, 1; got != want { |
| 375 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | func TestFindStringPrefixCandidateDisabledForRightToLeft(t *testing.T) { |
| 380 | re := &Regexp{ |
nothing calls this directly
no test coverage detected