Skip to content

Commit

Permalink
Expand NilError, True, False
Browse files Browse the repository at this point in the history
Workaround for golang/go#52237
  • Loading branch information
earthboundkid committed Apr 11, 2022
1 parent 4940f39 commit b320f5a
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions be.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,26 @@ func reflectValue(vp any) bool {
}
}

var (
// NilErr calls t.Fatal if value is not nil.
NilErr = Zero[error]
// True calls t.Fatal if value is not true.
True = Nonzero[bool]
// False calls t.Fatal if value is not false.
False = Zero[bool]
)
// NilErr calls t.Fatal if err is not nil.
func NilErr(t testing.TB, err error) {
t.Helper()
if err != nil {
t.Fatalf("got: %v", err)
}
}

// True calls t.Fatal if value is not true.
func True(t testing.TB, value bool) {
t.Helper()
if !value {
t.Fatalf("got: false")
}
}

// False calls t.Fatal if value is not false.
func False(t testing.TB, value bool) {
t.Helper()
if value {
t.Fatalf("got: true")
}
}

0 comments on commit b320f5a

Please sign in to comment.