mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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
This commit is contained in:
parent
7472f4c951
commit
ec23467e65
8 changed files with 384 additions and 106 deletions
37
src/pkg/gob/encoder_test.go
Normal file
37
src/pkg/gob/encoder_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package gob
|
||||
|
||||
import (
|
||||
"bytes";
|
||||
"gob";
|
||||
"os";
|
||||
"reflect";
|
||||
"strings";
|
||||
"testing";
|
||||
"unsafe";
|
||||
)
|
||||
|
||||
type ET2 struct {
|
||||
x string;
|
||||
}
|
||||
|
||||
type ET1 struct {
|
||||
a int;
|
||||
et2 *ET2;
|
||||
next *ET1;
|
||||
}
|
||||
|
||||
func TestBasicEncoder(t *testing.T) {
|
||||
b := new(bytes.Buffer);
|
||||
enc := NewEncoder(b);
|
||||
et1 := new(ET1);
|
||||
et1.a = 7;
|
||||
et1.et2 = new(ET2);
|
||||
enc.Encode(et1);
|
||||
if enc.state.err != nil {
|
||||
t.Error("encoder fail:", enc.state.err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue