You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
217 B

9 years ago
  1. package test
  2. import (
  3. "testing"
  4. )
  5. func AssertPanics(t *testing.T, msg string, f func()) {
  6. defer func() {
  7. if err := recover(); err == nil {
  8. t.Errorf("Should have panic'd, but didn't: %v", msg)
  9. }
  10. }()
  11. f()
  12. }