(t *testing.T)
| 336 | } |
| 337 | |
| 338 | func TestFindStringMatchStart(t *testing.T) { |
| 339 | re := &Regexp{} |
| 340 | |
| 341 | candidateByteIndex, ok, err := re.findStringMatchStart("abc", -1) |
| 342 | if err != nil { |
| 343 | t.Fatalf("findStringMatchStart failed: %v", err) |
| 344 | } |
| 345 | if !ok { |
| 346 | t.Fatal("expected candidate") |
| 347 | } |
| 348 | if got, want := candidateByteIndex, 0; got != want { |
| 349 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 350 | } |
| 351 | |
| 352 | re.options = RightToLeft |
| 353 | candidateByteIndex, ok, err = re.findStringMatchStart("abc", -1) |
| 354 | if err != nil { |
| 355 | t.Fatalf("findStringMatchStart failed: %v", err) |
| 356 | } |
| 357 | if !ok { |
| 358 | t.Fatal("expected candidate") |
| 359 | } |
| 360 | if got, want := candidateByteIndex, 3; got != want { |
| 361 | t.Fatalf("candidateByteIndex = %d, want %d", got, want) |
| 362 | } |
| 363 | |
| 364 | if _, _, err := re.findStringMatchStart("abc", 4); err == nil { |
| 365 | t.Fatal("expected startAt too large error") |
| 366 | } |
| 367 | if _, _, err := re.findStringMatchStart("aé", 2); err == nil { |
| 368 | t.Fatal("expected invalid rune boundary error") |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | func BenchmarkStringIndexPrefixesFilter(b *testing.B) { |
| 373 | prefixes := []string{ |
nothing calls this directly
no test coverage detected