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

Function TestErrorEquality

errors_test.go:231–251  ·  view source on GitHub ↗

errors.New, etc values are not expected to be compared by value but the change in errors#27 made them incomparable. Assert that various kinds of errors have a functional equality operator, even if the result of that equality is always false.

(t *testing.T)

Source from the content-addressed store, hash-verified

229// various kinds of errors have a functional equality operator, even
230// if the result of that equality is always false.
231func TestErrorEquality(t *testing.T) {
232 vals := []error{
233 nil,
234 io.EOF,
235 errors.New("EOF"),
236 New("EOF"),
237 Errorf("EOF"),
238 Wrap(io.EOF, "EOF"),
239 Wrapf(io.EOF, "EOF%d", 2),
240 WithMessage(nil, "whoops"),
241 WithMessage(io.EOF, "whoops"),
242 WithStack(io.EOF),
243 WithStack(nil),
244 }
245
246 for i := range vals {
247 for j := range vals {
248 _ = vals[i] == vals[j] // mustn't panic
249 }
250 }
251}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
ErrorfFunction · 0.85
WrapFunction · 0.85
WrapfFunction · 0.85
WithMessageFunction · 0.85
WithStackFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…