MCPcopy
hub / github.com/expr-lang/expr / TestError

Function TestError

internal/testify/assert/assertions_test.go:1479–1507  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1477func (*customError) Error() string { return "fail" }
1478
1479func TestError(t *testing.T) {
1480
1481 mockT := new(testing.T)
1482
1483 // start with a nil error
1484 var err error
1485
1486 False(t, Error(mockT, err), "Error should return False for nil arg")
1487
1488 // now set an error
1489 err = errors.New("some error")
1490
1491 True(t, Error(mockT, err), "Error with error should return True")
1492
1493 // go vet check
1494 True(t, Errorf(mockT, err, "example with %s", "formatted message"), "Errorf with error should return True")
1495
1496 // returning an empty error interface
1497 err = func() error {
1498 var err *customError
1499 return err
1500 }()
1501
1502 if err == nil { // err is not nil here!
1503 t.Errorf("Error should be nil due to empty interface: %s", err)
1504 }
1505
1506 True(t, Error(mockT, err), "Error should pass with empty error interface")
1507}
1508
1509func TestEqualError(t *testing.T) {
1510 mockT := new(testing.T)

Callers

nothing calls this directly

Calls 5

FalseFunction · 0.70
ErrorFunction · 0.70
TrueFunction · 0.70
ErrorfFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…