MCPcopy
hub / github.com/pkg/errors / testFormatRegexp

Function testFormatRegexp

format_test.go:387–407  ·  view source on GitHub ↗
(t *testing.T, n int, arg interface{}, format, want string)

Source from the content-addressed store, hash-verified

385}
386
387func testFormatRegexp(t *testing.T, n int, arg interface{}, format, want string) {
388 t.Helper()
389 got := fmt.Sprintf(format, arg)
390 gotLines := strings.SplitN(got, "\n", -1)
391 wantLines := strings.SplitN(want, "\n", -1)
392
393 if len(wantLines) > len(gotLines) {
394 t.Errorf("test %d: wantLines(%d) > gotLines(%d):\n got: %q\nwant: %q", n+1, len(wantLines), len(gotLines), got, want)
395 return
396 }
397
398 for i, w := range wantLines {
399 match, err := regexp.MatchString(w, gotLines[i])
400 if err != nil {
401 t.Fatal(err)
402 }
403 if !match {
404 t.Errorf("test %d: line %d: fmt.Sprintf(%q, err):\n got: %q\nwant: %q", n+1, i+1, format, got, want)
405 }
406 }
407}
408
409var stackLineR = regexp.MustCompile(`\.`)
410

Callers 8

TestFormatNewFunction · 0.85
TestFormatErrorfFunction · 0.85
TestFormatWrapFunction · 0.85
TestFormatWrapfFunction · 0.85
TestFormatWrappedNewFunction · 0.85
TestFrameFormatFunction · 0.85
TestStackTraceFunction · 0.85
TestStackTraceFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…