From 89496a6569e5cccff78a35628ab4057b11cf85a9 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 20 Jan 2013 13:41:53 -0600 Subject: Add tests for types with custom Error interface. --- spew/dump_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spew/dump_test.go') 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+")()\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+")()\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 { -- cgit v1.2.3