Skip to content

Commit

Permalink
shorten Empty and NotEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
asahasrabuddhe committed Aug 22, 2024
1 parent 241e0c6 commit 7bf0162
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,21 @@ func RequireFalse(t *testing.T, value bool, msgAndArgs ...interface{}) {
}

func Empty(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
pass := isEmpty(object)
if !pass {
if !isEmpty(object) {
t.Helper()
return fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...)
}

return pass
return true
}

func NotEmpty(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
pass := !isEmpty(object)
if !pass {
if isEmpty(object) {
t.Helper()
return fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...)
}

return pass
return true
}

func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
Expand Down

0 comments on commit 7bf0162

Please sign in to comment.