From 2c7459d4ba6de60b765ca0881041aeb517619d03 Mon Sep 17 00:00:00 2001 From: mreedell Date: Mon, 14 Apr 2014 15:20:53 -0400 Subject: [PATCH] Fixing issue 33 --- assert/assertions.go | 12 ++++++++++-- assert/assertions_test.go | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assert/assertions.go b/assert/assertions.go index c784e1b..36babfb 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -230,6 +230,7 @@ func isEmpty(object interface{}) bool { } objValue := reflect.ValueOf(object) + switch objValue.Kind() { case reflect.Map: fallthrough @@ -237,10 +238,17 @@ func isEmpty(object interface{}) bool { { return (objValue.Len() == 0) } + case reflect.Ptr: + { + switch object.(type) { + case *time.Time: + return object.(*time.Time).IsZero() + default: + return false + } + } } - return false - } // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a diff --git a/assert/assertions_test.go b/assert/assertions_test.go index bf1d727..3f0b8e6 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -335,6 +335,7 @@ func Test_isEmpty(t *testing.T) { True(t, isEmpty(0)) True(t, isEmpty(false)) True(t, isEmpty(map[string]string{})) + True(t, isEmpty(new(time.Time))) False(t, isEmpty("something")) False(t, isEmpty(errors.New("something")))