MCPcopy Create free account
hub / github.com/coregx/coregex / TestGoAWK_MatchPattern

Function TestGoAWK_MatchPattern

goawk_bench_test.go:31–66  ·  view source on GitHub ↗

============================================================================= Correctness Tests =============================================================================

(t *testing.T)

Source from the content-addressed store, hash-verified

29// =============================================================================
30
31func TestGoAWK_MatchPattern(t *testing.T) {
32 // Pattern: j[a-z]+p should match "jump" in the input
33 pattern := `j[a-z]+p`
34 input := goawkMatchInput
35
36 reCoregex := coregex.MustCompile(pattern)
37 reStdlib := regexp.MustCompile(pattern)
38
39 // Test FindString
40 gotCoregex := reCoregex.FindString(input)
41 gotStdlib := reStdlib.FindString(input)
42
43 if gotCoregex != gotStdlib {
44 t.Errorf("FindString mismatch: coregex=%q, stdlib=%q", gotCoregex, gotStdlib)
45 }
46
47 // Test FindStringIndex
48 idxCoregex := reCoregex.FindStringIndex(input)
49 idxStdlib := reStdlib.FindStringIndex(input)
50
51 if len(idxCoregex) != len(idxStdlib) {
52 t.Errorf("FindStringIndex length mismatch: coregex=%v, stdlib=%v", idxCoregex, idxStdlib)
53 } else if len(idxCoregex) == 2 {
54 if idxCoregex[0] != idxStdlib[0] || idxCoregex[1] != idxStdlib[1] {
55 t.Errorf("FindStringIndex mismatch: coregex=%v, stdlib=%v", idxCoregex, idxStdlib)
56 }
57 }
58
59 // Test MatchString
60 matchCoregex := reCoregex.MatchString(input)
61 matchStdlib := reStdlib.MatchString(input)
62
63 if matchCoregex != matchStdlib {
64 t.Errorf("MatchString mismatch: coregex=%v, stdlib=%v", matchCoregex, matchStdlib)
65 }
66}
67
68func TestGoAWK_SplitPattern(t *testing.T) {
69 // Pattern: f[a-z]x matches "fox", "fax", "fix"

Callers

nothing calls this directly

Calls 4

MustCompileFunction · 0.92
FindStringMethod · 0.80
FindStringIndexMethod · 0.80
MatchStringMethod · 0.80

Tested by

no test coverage detected