diff options
author | Rob Pike <r@golang.org> | 2009-07-09 14:33:43 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-07-09 14:33:43 -0700 |
commit | 5214e17d0bdbd365b14ae1aba8805fb761452ed6 (patch) | |
tree | c82ae9852c06a1b072d1a5407a6554d818cf4326 /src/pkg/gob/codec_test.go | |
parent | 10f8bfd26ece6a32c079fb3afe514c4f9963f67e (diff) | |
download | golang-5214e17d0bdbd365b14ae1aba8805fb761452ed6.tar.gz |
store ids rather than Types in the structs so they can be encoded.
change Type to gobType.
fix some bugs around recursive structures.
lots of cleanup.
add the first cut at a type encoder.
R=rsc
DELTA=400 (287 added, 11 deleted, 102 changed)
OCL=31401
CL=31406
Diffstat (limited to 'src/pkg/gob/codec_test.go')
-rw-r--r-- | src/pkg/gob/codec_test.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/pkg/gob/codec_test.go b/src/pkg/gob/codec_test.go index e25a719fa..23ff885f0 100644 --- a/src/pkg/gob/codec_test.go +++ b/src/pkg/gob/codec_test.go @@ -13,7 +13,6 @@ import ( "testing"; "unsafe"; ) -import "fmt" // TODO DELETE // Guarantee encoding format by comparing some encodings to hand-written values type EncodeT struct { @@ -560,6 +559,30 @@ func TestEndToEnd(t *testing.T) { } } +func TestNesting(t *testing.T) { + type RT struct { + a string; + next *RT + } + rt := new(RT); + rt.a = "level1"; + rt.next = new(RT); + rt.next.a = "level2"; + b := new(bytes.Buffer); + Encode(b, rt); + var drt RT; + Decode(b, &drt); + if drt.a != rt.a { + t.Errorf("nesting: encode expected %v got %v", *rt, drt); + } + if drt.next == nil { + t.Errorf("nesting: recursion failed"); + } + if drt.next.a != rt.next.a { + t.Errorf("nesting: encode expected %v got %v", *rt.next, *drt.next); + } +} + // These three structures have the same data with different indirections type T0 struct { a int; |