core/testutil/assert/asserts.go

37 lines
589 B
Go
Raw Normal View History

2023-05-19 04:12:21 +00:00
package assert
import (
"testing"
)
func WillPanic(t *testing.T, f func()) {
t.Helper()
defer func() { _ = recover() }()
f()
t.Fatalf("should have panicked")
}
func Equal(t *testing.T, expect, check interface{}) {
if expect != check {
t.Fatalf("%v:%v not equal", expect, check)
}
}
func NotEqual(t *testing.T, expect, check interface{}) {
if expect == check {
t.Fatalf("%v:%v equal", expect, check)
}
}
func NotNil(t *testing.T, v interface{}) {
if v == nil {
t.Fatalf("nil")
}
}
2024-01-01 16:55:54 +00:00
func NoError(t *testing.T, err error) {
if err != nil {
t.Fatalf(err.Error())
}
}