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

Function testFormatCompleteCompare

format_test.go:481–512  ·  view source on GitHub ↗
(t *testing.T, n int, arg interface{}, format string, want []string, detectStackBoundaries bool)

Source from the content-addressed store, hash-verified

479}
480
481func testFormatCompleteCompare(t *testing.T, n int, arg interface{}, format string, want []string, detectStackBoundaries bool) {
482 gotStr := fmt.Sprintf(format, arg)
483
484 got, err := parseBlocks(gotStr, detectStackBoundaries)
485 if err != nil {
486 t.Fatal(err)
487 }
488
489 if len(got) != len(want) {
490 t.Fatalf("test %d: fmt.Sprintf(%s, err) -> wrong number of blocks: got(%d) want(%d)\n got: %s\nwant: %s\ngotStr: %q",
491 n+1, format, len(got), len(want), prettyBlocks(got), prettyBlocks(want), gotStr)
492 }
493
494 for i := range got {
495 if strings.ContainsAny(want[i], "\n") {
496 // Match as stack
497 match, err := regexp.MatchString(want[i], got[i])
498 if err != nil {
499 t.Fatal(err)
500 }
501 if !match {
502 t.Fatalf("test %d: block %d: fmt.Sprintf(%q, err):\ngot:\n%q\nwant:\n%q\nall-got:\n%s\nall-want:\n%s\n",
503 n+1, i+1, format, got[i], want[i], prettyBlocks(got), prettyBlocks(want))
504 }
505 } else {
506 // Match as message
507 if got[i] != want[i] {
508 t.Fatalf("test %d: fmt.Sprintf(%s, err) at block %d got != want:\n got: %q\nwant: %q", n+1, format, i+1, got[i], want[i])
509 }
510 }
511 }
512}
513
514type wrapper struct {
515 wrap func(err error) error

Callers 4

TestFormatWithStackFunction · 0.85
TestFormatWithMessageFunction · 0.85
TestFormatGenericFunction · 0.85
testGenericRecursiveFunction · 0.85

Calls 2

parseBlocksFunction · 0.85
prettyBlocksFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…