MCPcopy Index your code
hub / github.com/bracesdev/errtrace / TestFormatVerbs

Function TestFormatVerbs

errtrace_test.go:102–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestFormatVerbs(t *testing.T) {
103 err := errors.New("error")
104 wrapped := errtrace.Wrap(err)
105
106 tests := []struct {
107 name string
108 fmt string
109 want string
110 }{
111 {
112 name: "verb s",
113 fmt: "%s",
114 want: "error",
115 },
116 {
117 name: "verb v",
118 fmt: "%v",
119 want: "error",
120 },
121 {
122 name: "verb q",
123 fmt: "%q",
124 want: `"error"`,
125 },
126 {
127 name: "padded string",
128 fmt: "%10s",
129 want: " error",
130 },
131 }
132
133 for _, tt := range tests {
134 t.Run(tt.name, func(t *testing.T) {
135 if want, got := tt.want, fmt.Sprintf(tt.fmt, err); want != got {
136 t.Errorf("unwrapped: want %q, got %q", want, got)
137 }
138
139 if want, got := tt.want, fmt.Sprintf(tt.fmt, wrapped); want != got {
140 t.Errorf("wrapped: want %q, got %q", want, got)
141 }
142 })
143 }
144}
145
146func TestFormat(t *testing.T) {
147 e1 := errtrace.New("e1")

Callers

nothing calls this directly

Calls 2

WrapFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected