mirror of
https://github.com/stretchr/testify.git
synced 2025-04-27 13:13:19 +00:00
Merge pull request #50 from mikereedell/master
Fixing issue 33 Looks good! Thanks!
This commit is contained in:
commit
84ae2f5461
@ -230,6 +230,7 @@ func isEmpty(object interface{}) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
objValue := reflect.ValueOf(object)
|
objValue := reflect.ValueOf(object)
|
||||||
|
|
||||||
switch objValue.Kind() {
|
switch objValue.Kind() {
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
fallthrough
|
fallthrough
|
||||||
@ -237,10 +238,17 @@ func isEmpty(object interface{}) bool {
|
|||||||
{
|
{
|
||||||
return (objValue.Len() == 0)
|
return (objValue.Len() == 0)
|
||||||
}
|
}
|
||||||
}
|
case reflect.Ptr:
|
||||||
|
{
|
||||||
|
switch object.(type) {
|
||||||
|
case *time.Time:
|
||||||
|
return object.(*time.Time).IsZero()
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a
|
||||||
|
@ -335,6 +335,7 @@ func Test_isEmpty(t *testing.T) {
|
|||||||
True(t, isEmpty(0))
|
True(t, isEmpty(0))
|
||||||
True(t, isEmpty(false))
|
True(t, isEmpty(false))
|
||||||
True(t, isEmpty(map[string]string{}))
|
True(t, isEmpty(map[string]string{}))
|
||||||
|
True(t, isEmpty(new(time.Time)))
|
||||||
|
|
||||||
False(t, isEmpty("something"))
|
False(t, isEmpty("something"))
|
||||||
False(t, isEmpty(errors.New("something")))
|
False(t, isEmpty(errors.New("something")))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user