mirror of https://github.com/stretchr/testify.git
Don't panic when underlying type is not .IsNil()-able (eg. string)
parent
3df0bce8cb
commit
d35afcda84
|
@ -173,8 +173,12 @@ func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
if object == nil {
|
if object == nil {
|
||||||
success = false
|
success = false
|
||||||
} else if reflect.ValueOf(object).IsNil() {
|
} else {
|
||||||
success = false
|
value := reflect.ValueOf(object)
|
||||||
|
kind := value.Kind()
|
||||||
|
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
|
||||||
|
success = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
|
@ -201,8 +205,12 @@ func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
if object == nil {
|
if object == nil {
|
||||||
return true
|
return true
|
||||||
} else if reflect.ValueOf(object).IsNil() {
|
} else {
|
||||||
return true
|
value := reflect.ValueOf(object)
|
||||||
|
kind := value.Kind()
|
||||||
|
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(message) > 0 {
|
if len(message) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue