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())...)