encode and decode for nested structures.

fix a bug in delta encoding: only update the delta-base if something is marshaled.

R=rsc
DELTA=154  (94 added, 56 deleted, 4 changed)
OCL=31069
CL=31071
This commit is contained in:
Rob Pike 2009-07-02 13:43:47 -07:00
parent 1ca1e1befa
commit 77baac11e1
3 changed files with 96 additions and 58 deletions

View file

@ -569,10 +569,14 @@ func TestScalarDecInstructions(t *testing.T) {
func TestEncode(t *testing.T) {
type T2 struct {
t string
}
type T1 struct {
a, b,c int;
s string;
y []byte;
t *T2;
}
t1 := &T1{
a: 17,
@ -580,6 +584,7 @@ func TestEncode(t *testing.T) {
c: -5,
s: "Now is the time",
y: strings.Bytes("hello, sailor"),
t: &T2{"this is T2"},
};
b := new(bytes.Buffer);
Encode(b, t1);