cosmos-sdk/testutil/assert_helpers.go
2023-02-11 16:59:16 +00:00

26 lines
379 B
Go

package testutil
import "testing"
func AssertPanics(t *testing.T, f func()) {
panicked := false
defer func() {
if r := recover(); r != nil {
panicked = true
}
}()
f()
if !panicked {
t.Errorf("should panic")
}
}
func AssertNotPanics(t *testing.T, f func()) {
defer func() {
if r := recover(); r != nil {
t.Errorf("should not panic: %v", r)
}
}()
f()
}