diff options
Diffstat (limited to 'check/check.go')
| -rw-r--r-- | check/check.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/check/check.go b/check/check.go index ddb9d5a..ffc4bb5 100644 --- a/check/check.go +++ b/check/check.go @@ -3,6 +3,7 @@ package check import ( "errors" "fmt" + "reflect" "strings" "github.com/eugenetriguba/checkmate" @@ -23,7 +24,17 @@ func Nil(t checkmate.TestingT, value any, msgAndArgs ...any) bool { msgAndArgs = []any{"expected value to be nil, got %v", value} } - return check(t, value == nil, msgAndArgs...) + isNil := false + val := reflect.ValueOf(value) + if val.Kind() == reflect.Ptr { + if val.IsNil() { + isNil = true + } + } else if value == nil { + isNil = true + } + + return check(t, isNil, msgAndArgs...) } // NotNil checks whether the value does not equal nil. |