From 8a9e395f5f5977f17d1c51b085948aad30a4c5dc Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Fri, 10 Jul 2009 13:50:44 -0700 Subject: [PATCH] one more piece of testing: 2nd send should not send type info. R=rsc DELTA=25 (25 added, 0 deleted, 0 changed) OCL=31460 CL=31460 --- src/pkg/gob/encoder_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/pkg/gob/encoder_test.go b/src/pkg/gob/encoder_test.go index c762a18763..ad37e2b2b3 100644 --- a/src/pkg/gob/encoder_test.go +++ b/src/pkg/gob/encoder_test.go @@ -90,4 +90,29 @@ func TestBasicEncoder(t *testing.T) { if b.Len() != 0 { t.Error("not at eof;", b.Len(), "bytes left") } + + // Now do it again. This time we should see only the type id and value. + b.Reset(); + enc.Encode(et1); + if enc.state.err != nil { + t.Error("2nd round: encoder fail:", enc.state.err) + } + // 5a) The type id for the et1 value + newId1 = DecodeInt(state); + if newId1 != -id1 { + t.Fatal("2nd round: expected Et1 id", -id1, "got", newId1); + } + // 6a) The value of et1 + newEt1 = new(ET1); + err = Decode(b, newEt1); + if err != nil { + t.Fatal("2nd round: error decoding ET1 value:", err); + } + if !reflect.DeepEqual(et1, newEt1) { + t.Fatalf("2nd round: invalid data for et1: expected %+v; got %+v\n", *et1, *newEt1); + } + // 7a) EOF + if b.Len() != 0 { + t.Error("2nd round: not at eof;", b.Len(), "bytes left") + } }