PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value. assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{})
| 1228 | // |
| 1229 | // assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) |
| 1230 | func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { |
| 1231 | if h, ok := t.(tHelper); ok { |
| 1232 | h.Helper() |
| 1233 | } |
| 1234 | |
| 1235 | funcDidPanic, panicValue, panickedStack := didPanic(f) |
| 1236 | if !funcDidPanic { |
| 1237 | return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) |
| 1238 | } |
| 1239 | if panicValue != expected { |
| 1240 | return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, expected, panicValue, panickedStack), msgAndArgs...) |
| 1241 | } |
| 1242 | |
| 1243 | return true |
| 1244 | } |
| 1245 | |
| 1246 | // PanicsWithError asserts that the code inside the specified PanicTestFunc |
| 1247 | // panics, and that the recovered panic value is an error that satisfies the |
searching dependent graphs…