Panics asserts that the code inside the specified PanicTestFunc panics. assert.Panics(t, func(){ GoCrazy() })
(t TestingT, f PanicTestFunc, msgAndArgs ...interface{})
| 1298 | // |
| 1299 | // assert.Panics(t, func(){ GoCrazy() }) |
| 1300 | func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { |
| 1301 | if h, ok := t.(tHelper); ok { |
| 1302 | h.Helper() |
| 1303 | } |
| 1304 | |
| 1305 | if funcDidPanic, panicValue, _ := didPanic(f); !funcDidPanic { |
| 1306 | return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) |
| 1307 | } |
| 1308 | |
| 1309 | return true |
| 1310 | } |
| 1311 | |
| 1312 | // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that |
| 1313 | // the recovered panic value equals the expected panic value. |