summaryrefslogtreecommitdiff
path: root/spew/dump_test.go
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2013-09-09 20:42:50 -0500
committerDave Collins <[email protected]>2013-09-09 20:43:39 -0500
commit8f603f64f931c41a1b91b27f6a595fc542557579 (patch)
tree15eb0845cf5240f419d13bc8c494f0750ecb7de3 /spew/dump_test.go
parent7ea732c827c17c2e5cf8655aac42e3abe058ef17 (diff)
Add tests for nil slice change.
This commit adds tests for the nil slice change.
Diffstat (limited to 'spew/dump_test.go')
-rw-r--r--spew/dump_test.go14
1 files changed, 14 insertions, 0 deletions
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+")(<nil>)\n")
+
+ // Nil slice.
+ v5 := []int(nil)
+ nv5 := (*[]int)(nil)
+ pv5 := &v5
+ v5Addr := fmt.Sprintf("%p", pv5)
+ pv5Addr := fmt.Sprintf("%p", &pv5)
+ v5t := "[]int"
+ v5s := "<nil>"
+ addDumpTest(v5, "("+v5t+") "+v5s+"\n")
+ addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n")
+ addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n")
+ addDumpTest(nv5, "(*"+v5t+")(<nil>)\n")
}
func addStringDumpTests() {