From 86c5e22fa825920412607526323b9404150b6c54 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 22 Jan 2015 16:43:07 +0000 Subject: [PATCH] another assert --- testing/util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/util.go b/testing/util.go index 809cef36..2222fd85 100644 --- a/testing/util.go +++ b/testing/util.go @@ -58,6 +58,12 @@ func AssertType(t *testing.T, got interface{}, wanted interface{}, desc string) } } +func AssertEmpty(t *testing.T, array interface{}, desc string) { + if reflect.ValueOf(array).Len() != 0 { + Fatalf(t, "Expected empty %s but got %s", desc, array) + } +} + // Like testing.Fatalf, but adds the stack trace of the current call func Fatalf(t *testing.T, format string, args ...interface{}) { t.Fatalf(format+"\n%s", append(args, StackTrace())...)