From 9270ae09c1b7e0a809bedb173369fc5f72782940 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 5 Jan 2023 13:19:08 -0800 Subject: [PATCH] assert: Add Equal and NotEqual [ci-base] --- assert/assert.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/assert/assert.go b/assert/assert.go index 1ac8233..ff490d4 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -63,18 +63,35 @@ func Runes(tb testing.TB, exp, got string) { } func TestdataJSON(tb testing.TB, got interface{}) { + tb.Helper() err := diff.TestdataJSON(filepath.Join("testdata", tb.Name()), got) Success(tb, err) } func Testdata(tb testing.TB, ext string, got []byte) { + tb.Helper() err := diff.Testdata(filepath.Join("testdata", tb.Name()), ext, got) Success(tb, err) } -func Close(t *testing.T, c io.Closer) { +func Close(tb testing.TB, c io.Closer) { + tb.Helper() err := c.Close() if err != nil { - t.Fatalf("failed to close %T: %v", c, err) + tb.Fatalf("failed to close %T: %v", c, err) + } +} + +func Equal(tb testing.TB, exp, got interface{}) { + tb.Helper() + if exp != got { + tb.Fatalf("expected %[1]p %#[1]v but got %[2]p %#[2]v", exp, got) + } +} + +func NotEqual(tb testing.TB, v1, v2 interface{}) { + tb.Helper() + if v1 == v2 { + tb.Fatalf("did not expect %[1]p %#[1]v", v2) } }