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

Function TestFormatWrap

format_test.go:68–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestFormatWrap(t *testing.T) {
69 tests := []struct {
70 error
71 format string
72 want string
73 }{{
74 Wrap(New("error"), "error2"),
75 "%s",
76 "error2: error",
77 }, {
78 Wrap(New("error"), "error2"),
79 "%v",
80 "error2: error",
81 }, {
82 Wrap(New("error"), "error2"),
83 "%+v",
84 "error\n" +
85 "github.com/pkg/errors.TestFormatWrap\n" +
86 "\t.+/github.com/pkg/errors/format_test.go:82",
87 }, {
88 Wrap(io.EOF, "error"),
89 "%s",
90 "error: EOF",
91 }, {
92 Wrap(io.EOF, "error"),
93 "%v",
94 "error: EOF",
95 }, {
96 Wrap(io.EOF, "error"),
97 "%+v",
98 "EOF\n" +
99 "error\n" +
100 "github.com/pkg/errors.TestFormatWrap\n" +
101 "\t.+/github.com/pkg/errors/format_test.go:96",
102 }, {
103 Wrap(Wrap(io.EOF, "error1"), "error2"),
104 "%+v",
105 "EOF\n" +
106 "error1\n" +
107 "github.com/pkg/errors.TestFormatWrap\n" +
108 "\t.+/github.com/pkg/errors/format_test.go:103\n",
109 }, {
110 Wrap(New("error with space"), "context"),
111 "%q",
112 `"context: error with space"`,
113 }}
114
115 for i, tt := range tests {
116 testFormatRegexp(t, i, tt.error, tt.format, tt.want)
117 }
118}
119
120func TestFormatWrapf(t *testing.T) {
121 tests := []struct {

Callers

nothing calls this directly

Calls 3

WrapFunction · 0.85
NewFunction · 0.85
testFormatRegexpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…