Skip to content

Commit

Permalink
assert: Add Equal and NotEqual [ci-base]
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Jan 5, 2023
1 parent 0956d77 commit 9270ae0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 9270ae0

Please sign in to comment.