diff options
| author | Dave Collins <[email protected]> | 2013-01-20 19:55:55 -0600 |
|---|---|---|
| committer | Dave Collins <[email protected]> | 2013-01-20 19:55:55 -0600 |
| commit | f2641d5e6e2ffc7bb5d847b6552149f4f3b02136 (patch) | |
| tree | 3fee583a4333a35dd7824d1f717d550389ee1f52 /spew/dump_test.go | |
| parent | cddf8663bd7f61d62278c3fc6d2a2711fa87e115 (diff) | |
Add tests for structs with multiple equiv fields.
This commit adds tests for a struct which has an embedded struct pointer
and a field that is a pointer to the same object. This ensures the cycle
detection is properly reset between fields.
Diffstat (limited to 'spew/dump_test.go')
| -rw-r--r-- | spew/dump_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spew/dump_test.go b/spew/dump_test.go index abe0a28..7dc9e73 100644 --- a/spew/dump_test.go +++ b/spew/dump_test.go @@ -39,6 +39,7 @@ base test element are also tested to ensure proper indirection across all types. - Struct that contains another struct - Struct that contains custom type with Stringer pointer interface via both exported and unexported fields +- Struct that contains embedded struct and field to same struct - Uintptr to 0 (null pointer) - Uintptr address of real variable - Unsafe.Pointer to 0 (null pointer) @@ -542,6 +543,25 @@ func addStructDumpTests() { addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") addDumpTest(nv3, "(*"+v3t+")(<nil>)\n") + + // Struct that contains embedded struct and field to same struct. + e := embed{"embedstr"} + v4 := embedwrap{embed: &e, e: &e} + nv4 := (*embedwrap)(nil) + pv4 := &v4 + eAddr := fmt.Sprintf("%p", &e) + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "spew_test.embedwrap" + v4t2 := "spew_test.embed" + v4t3 := "string" + v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 + + ") \"embedstr\"\n }),\n e: (*" + v4t2 + ")(" + eAddr + ")({\n" + + " a: (" + v4t3 + ") \"embedstr\"\n })\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")(<nil>)\n") } func addUintptrDumpTests() { |
