24 lines
381 B
Go
24 lines
381 B
Go
package testx
|
|
|
|
import "testing"
|
|
|
|
func Expect(t *testing.T, cond bool, message ...any) {
|
|
t.Helper()
|
|
|
|
if !cond {
|
|
if len(message) == 0 {
|
|
message = append(message, "expectation failed")
|
|
}
|
|
|
|
str := message[0].(string)
|
|
t.Fatalf(str, message[1:]...)
|
|
}
|
|
}
|
|
|
|
func ShouldPanic(t *testing.T, f func()) {
|
|
t.Helper()
|
|
|
|
defer func() { recover() }()
|
|
f()
|
|
t.Fatal("expected panic")
|
|
}
|