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

Function TestErrorMessageFormat

error_test.go:13–42  ·  view source on GitHub ↗

TestErrorMessageFormat verifies that error messages match stdlib format. stdlib returns *syntax.Error directly with format: "error parsing regexp: ..."

(t *testing.T)

Source from the content-addressed store, hash-verified

11// TestErrorMessageFormat verifies that error messages match stdlib format.
12// stdlib returns *syntax.Error directly with format: "error parsing regexp: ..."
13func TestErrorMessageFormat(t *testing.T) {
14 patterns := []string{
15 "[invalid",
16 `\`,
17 "(abc",
18 "*abc",
19 `\8`,
20 }
21
22 for _, pattern := range patterns {
23 t.Run(pattern, func(t *testing.T) {
24 _, stdlibErr := regexp.Compile(pattern)
25 _, ourErr := Compile(pattern)
26
27 if stdlibErr == nil {
28 t.Skip("stdlib accepts this pattern")
29 }
30
31 if ourErr == nil {
32 t.Fatalf("Compile(%q) expected error, got nil", pattern)
33 }
34
35 // Error messages should match exactly
36 if ourErr.Error() != stdlibErr.Error() {
37 t.Errorf("error message mismatch:\n got: %q\n want: %q",
38 ourErr.Error(), stdlibErr.Error())
39 }
40 })
41 }
42}
43
44// TestMustCompilePanicFormat verifies MustCompile panic message matches stdlib format.
45func TestMustCompilePanicFormat(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CompileMethod · 0.80
CompileFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected