diff options
| author | Dave Collins <[email protected]> | 2013-01-20 12:31:42 -0600 |
|---|---|---|
| committer | Dave Collins <[email protected]> | 2013-01-20 12:31:42 -0600 |
| commit | ad1d81b355a1890f4cd7476b1d1e2e1f52541dd5 (patch) | |
| tree | c8f7bfe9bb3a55ac1241f7d712dd4e76240f6fab /spew/dump_test.go | |
| parent | 5c8d842977941cdb1663827b8c6a93046e211bbb (diff) | |
Add tests for custom type that panics in Stringer.
Diffstat (limited to 'spew/dump_test.go')
| -rw-r--r-- | spew/dump_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spew/dump_test.go b/spew/dump_test.go index f3c033b..1310906 100644 --- a/spew/dump_test.go +++ b/spew/dump_test.go @@ -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 @@ -748,6 +749,21 @@ func addCircularDumpTests() { addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n") } +func addPanicDumpTests() { + // 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" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")(<nil>)\n") +} + // TestDump executes all of the tests described by dumpTests. func TestDump(t *testing.T) { // Setup tests. @@ -767,6 +783,7 @@ func TestDump(t *testing.T) { addChanDumpTests() addFuncDumpTests() addCircularDumpTests() + addPanicDumpTests() t.Logf("Running %d tests", len(dumpTests)) for i, test := range dumpTests { |
