|
|
@@ -50,6 +50,7 @@ base test element are also tested to ensure proper indirection across all types.
|
|
|
- Struct that is circular through self referencing
|
|
|
- Structs that are circular through cross referencing
|
|
|
- Structs that are indirectly circular
|
|
|
+- Type that panics in its Stringer interface
|
|
|
*/
|
|
|
|
|
|
package spew_test
|
|
|
@@ -1222,6 +1223,33 @@ func addCircularFormatterTests() {
|
|
|
addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s8)
|
|
|
}
|
|
|
|
|
|
+func addPanicFormatterTests() {
|
|
|
+ // Type that panics in its Stringer interface.
|
|
|
+ v := panicer(127)
|
|
|
+ nv := (*panicer)(nil)
|
|
|
+ pv := &v
|
|
|
+ vAddr := fmt.Sprintf("%p", pv)
|
|
|
+ pvAddr := fmt.Sprintf("%p", &pv)
|
|
|
+ vt := "spew_test.panicer"
|
|
|
+ vs := "(PANIC=test panic)127"
|
|
|
+ addFormatterTest("%v", v, vs)
|
|
|
+ addFormatterTest("%v", pv, "<*>"+vs)
|
|
|
+ addFormatterTest("%v", &pv, "<**>"+vs)
|
|
|
+ addFormatterTest("%v", nv, "<nil>")
|
|
|
+ addFormatterTest("%+v", v, vs)
|
|
|
+ addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
|
|
|
+ addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
|
|
|
+ addFormatterTest("%+v", nv, "<nil>")
|
|
|
+ addFormatterTest("%#v", v, "("+vt+")"+vs)
|
|
|
+ addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
|
|
|
+ addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
|
|
|
+ addFormatterTest("%#v", nv, "(*"+vt+")"+"<nil>")
|
|
|
+ addFormatterTest("%#+v", v, "("+vt+")"+vs)
|
|
|
+ addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
|
|
|
+ addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
|
|
|
+ addFormatterTest("%#+v", nv, "(*"+vt+")"+"<nil>")
|
|
|
+}
|
|
|
+
|
|
|
// TestFormatter executes all of the tests described by formatterTests.
|
|
|
func TestFormatter(t *testing.T) {
|
|
|
// Setup tests.
|
|
|
@@ -1241,6 +1269,7 @@ func TestFormatter(t *testing.T) {
|
|
|
addChanFormatterTests()
|
|
|
addFuncFormatterTests()
|
|
|
addCircularFormatterTests()
|
|
|
+ addPanicFormatterTests()
|
|
|
|
|
|
t.Logf("Running %d tests", len(formatterTests))
|
|
|
for i, test := range formatterTests {
|