-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Lines 390 to 410 in b89eecf
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { | |
if h, ok := t.(tHelper); ok { | |
h.Helper() | |
} | |
if !isNil(object) { | |
return true | |
} | |
return Fail(t, "Expected value not to be nil.", msgAndArgs...) | |
} | |
// isNil checks if a specified object is nil or not, without Failing. | |
func isNil(object interface{}) bool { | |
if object == nil { | |
return true | |
} | |
value := reflect.ValueOf(object) | |
kind := value.Kind() | |
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { | |
return true | |
} |
isNil
will always return false, so NotNil
will always return true for int, string, struct, etc.
I would expect it to error with "invalid type".