Don't panic when underlying type is not .IsNil()-able (eg. string)

This commit is contained in:
Joshua Elliott 2013-05-23 14:54:54 -06:00
parent 3df0bce8cb
commit d35afcda84

View File

@ -173,9 +173,13 @@ func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
if object == nil {
success = false
} else if reflect.ValueOf(object).IsNil() {
} else {
value := reflect.ValueOf(object)
kind := value.Kind()
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
success = false
}
}
if !success {
@ -201,9 +205,13 @@ func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
if object == nil {
return true
} else if reflect.ValueOf(object).IsNil() {
} else {
value := reflect.ValueOf(object)
kind := value.Kind()
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
return true
}
}
if len(message) > 0 {
t.Errorf("\r%s\r\tLocation:\t%s\n\r\tError:\t\tExpected nil, but got: %#v\n\r\tMessages:\t%s\n\r", getWhitespaceString(), CallerInfo(), object, message)