From 8f603f64f931c41a1b91b27f6a595fc542557579 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 9 Sep 2013 20:42:50 -0500 Subject: Add tests for nil slice change. This commit adds tests for the nil slice change. --- spew/dump_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spew/dump_test.go') diff --git a/spew/dump_test.go b/spew/dump_test.go index b15517c..3a50650 100644 --- a/spew/dump_test.go +++ b/spew/dump_test.go @@ -31,6 +31,7 @@ base test element are also tested to ensure proper indirection across all types. - Slice containing type with custom formatter on pointer receiver only - Slice containing interfaces - Slice containing bytes +- Nil slice - Standard string - Nil interface - Sub-interface @@ -439,6 +440,19 @@ func addSliceDumpTests() { addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") addDumpTest(nv4, "(*"+v4t+")()\n") + + // Nil slice. + v5 := []int(nil) + nv5 := (*[]int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "[]int" + v5s := "" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") } func addStringDumpTests() { -- cgit v1.2.3