(t *testing.T)
| 1553 | } |
| 1554 | |
| 1555 | func TestStdlibCompat_Count(t *testing.T) { |
| 1556 | tests := []struct { |
| 1557 | pattern string |
| 1558 | input string |
| 1559 | }{ |
| 1560 | {`a`, "banana"}, |
| 1561 | {`\d+`, "a1b22c333d4444"}, |
| 1562 | {`\w+`, "hello world foo bar"}, |
| 1563 | {`[aeiou]`, "hello world"}, |
| 1564 | {`x`, "no match here"}, |
| 1565 | } |
| 1566 | |
| 1567 | for _, tc := range tests { |
| 1568 | t.Run(tc.pattern+"_"+tc.input, func(t *testing.T) { |
| 1569 | stdRe := regexp.MustCompile(tc.pattern) |
| 1570 | cgRe := MustCompile(tc.pattern) |
| 1571 | |
| 1572 | // stdlib doesn't have Count, but we can compare with FindAll |
| 1573 | stdAll := stdRe.FindAllString(tc.input, -1) |
| 1574 | cgCount := cgRe.CountString(tc.input, -1) |
| 1575 | |
| 1576 | if len(stdAll) != cgCount { |
| 1577 | t.Errorf("Count(%q, %q):\n stdlib FindAll: %d\n coregex Count: %d", |
| 1578 | tc.pattern, tc.input, len(stdAll), cgCount) |
| 1579 | } |
| 1580 | }) |
| 1581 | } |
| 1582 | } |
| 1583 | |
| 1584 | func TestStdlibCompat_LiteralMatch(t *testing.T) { |
| 1585 | // Use MustCompile to verify literal matching works same as stdlib |
nothing calls this directly
no test coverage detected