From f28ee4c120a248d06ad4b09d9fea8105cb192b48 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 31 Jul 2022 13:49:57 +0100 Subject: Add T.Assert and T.AssertNot --- testing.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testing.go b/testing.go index ba22828..40b0c42 100644 --- a/testing.go +++ b/testing.go @@ -20,6 +20,15 @@ type T struct { wg sync.WaitGroup } +func (t *T) Assert(b bool) bool { + t.Helper() + + if !b { + t.Error("\nexepected value to be true") + } + return b +} + func (t *T) AssertEqual(exp, actual any) bool { t.Helper() @@ -67,6 +76,15 @@ func (t *T) AssertPanicsWith(f func(), exp any) (b bool) { return true } +func (t *T) AssertNot(b bool) bool { + t.Helper() + + if b { + t.Error("\nexpected value to be false") + } + return !b +} + func (t *T) AssertNotEqual(notExp, actual any) bool { t.Helper() -- cgit v1.2.3-70-g09d2