diff options
| author | Dave Collins <[email protected]> | 2013-01-20 13:41:53 -0600 |
|---|---|---|
| committer | Dave Collins <[email protected]> | 2013-01-20 13:41:53 -0600 |
| commit | 89496a6569e5cccff78a35628ab4057b11cf85a9 (patch) | |
| tree | 76b665ea26ade94f3ab90d9419ce308b1da71981 /spew/dump_test.go | |
| parent | 57a610269f12551528d76bd46c84dbbb308cc49c (diff) | |
Add tests for types with custom Error interface.
Diffstat (limited to 'spew/dump_test.go')
| -rw-r--r-- | spew/dump_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spew/dump_test.go b/spew/dump_test.go index f4de975..0d282c2 100644 --- a/spew/dump_test.go +++ b/spew/dump_test.go @@ -734,6 +734,21 @@ func addPanicDumpTests() { addDumpTest(nv, "(*"+vt+")(<nil>)\n") } +func addErrorDumpTests() { + // Type that has a custom Error interface. + v := customError(127) + nv := (*customError)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.customError" + vs := "error: 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. @@ -754,6 +769,7 @@ func TestDump(t *testing.T) { addFuncDumpTests() addCircularDumpTests() addPanicDumpTests() + addErrorDumpTests() t.Logf("Running %d tests", len(dumpTests)) for i, test := range dumpTests { |
