(t *testing.T)
| 352 | } |
| 353 | |
| 354 | func TestMatchStringAgreesWithFindStringMatch(t *testing.T) { |
| 355 | tests := []struct { |
| 356 | pattern string |
| 357 | input string |
| 358 | }{ |
| 359 | {`needle`, strings.Repeat("x", 100) + "needle"}, |
| 360 | {`\bcat\b`, strings.Repeat("漢", 20) + " cat "}, |
| 361 | {`\bcat\b`, strings.Repeat("x", 100) + "cat"}, |
| 362 | {`(?<=x)foo`, strings.Repeat("z", 40) + "xfoo"}, |
| 363 | {`(?<=x)foo`, strings.Repeat("z", 40) + "yfoo"}, |
| 364 | {`apple|tiger`, strings.Repeat("z", 40) + "tiger9"}, |
| 365 | {`\Gfoo`, "xxfoo"}, |
| 366 | {`\Gfoo`, strings.Repeat("x", 80) + "foo"}, |
| 367 | {`(?m)^foo`, "foo\nfoo"}, |
| 368 | } |
| 369 | for _, tt := range tests { |
| 370 | re := MustCompile(tt.pattern) |
| 371 | ok, err := re.MatchString(tt.input) |
| 372 | if err != nil { |
| 373 | t.Fatalf("%s MatchString(%q): %v", tt.pattern, tt.input, err) |
| 374 | } |
| 375 | m, err := re.FindStringMatch(tt.input) |
| 376 | if err != nil { |
| 377 | t.Fatalf("%s FindStringMatch(%q): %v", tt.pattern, tt.input, err) |
| 378 | } |
| 379 | if ok != (m != nil) { |
| 380 | t.Fatalf("%s on %q: MatchString=%v FindStringMatch=%v", tt.pattern, tt.input, ok, m != nil) |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | func TestNegatedClassNotConvertedToPrefixes(t *testing.T) { |
| 386 | re := MustCompile(`a[^bc]d`) |
nothing calls this directly
no test coverage detected