MCPcopy Create free account
hub / github.com/stretchr/testify / TestNotErrorAs

Function TestNotErrorAs

assert/assertions_test.go:3374–3397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3372}
3373
3374func TestNotErrorAs(t *testing.T) {
3375 tests := []struct {
3376 err error
3377 result bool
3378 }{
3379 {fmt.Errorf("wrap: %w", &customError{}), false},
3380 {io.EOF, true},
3381 {nil, true},
3382 }
3383 for _, tt := range tests {
3384 tt := tt
3385 var target *customError
3386 t.Run(fmt.Sprintf("NotErrorAs(%#v,%#v)", tt.err, target), func(t *testing.T) {
3387 mockT := new(testing.T)
3388 res := NotErrorAs(mockT, tt.err, &target)
3389 if res != tt.result {
3390 t.Errorf("NotErrorAs(%#v,%#v) should not return %t", tt.err, target, tt.result)
3391 }
3392 if res == mockT.Failed() {
3393 t.Errorf("The test result (%t) should be reflected in the testing.T type (%t)", res, !mockT.Failed())
3394 }
3395 })
3396 }
3397}

Callers

nothing calls this directly

Calls 4

FailedMethod · 0.80
NotErrorAsFunction · 0.70
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected