summaryrefslogtreecommitdiffstats
path: root/libgo/go/gob/encoder_test.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-20 00:18:15 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-20 00:18:15 +0000
commit84911de8492fb75007eec6bfa4abb7905439f93c (patch)
treec891bdec1e6f073f73fedeef23718bc3ac30d499 /libgo/go/gob/encoder_test.go
parentad33e6a8510b48571eaef50af339892925108830 (diff)
downloadppe42-gcc-84911de8492fb75007eec6bfa4abb7905439f93c.tar.gz
ppe42-gcc-84911de8492fb75007eec6bfa4abb7905439f93c.zip
Update to current version of Go library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173931 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/gob/encoder_test.go')
-rw-r--r--libgo/go/gob/encoder_test.go39
1 files changed, 37 insertions, 2 deletions
diff --git a/libgo/go/gob/encoder_test.go b/libgo/go/gob/encoder_test.go
index a0c713b81df..792afbd7752 100644
--- a/libgo/go/gob/encoder_test.go
+++ b/libgo/go/gob/encoder_test.go
@@ -170,7 +170,7 @@ func TestTypeToPtrType(t *testing.T) {
A int
}
t0 := Type0{7}
- t0p := (*Type0)(nil)
+ t0p := new(Type0)
if err := encAndDec(t0, t0p); err != nil {
t.Error(err)
}
@@ -339,7 +339,7 @@ func TestSingletons(t *testing.T) {
continue
}
// Get rid of the pointer in the rhs
- val := reflect.NewValue(test.out).(*reflect.PtrValue).Elem().Interface()
+ val := reflect.ValueOf(test.out).Elem().Interface()
if !reflect.DeepEqual(test.in, val) {
t.Errorf("decoding singleton: expected %v got %v", test.in, val)
}
@@ -514,3 +514,38 @@ func TestNestedInterfaces(t *testing.T) {
t.Fatalf("final value %d; expected %d", inner.A, 7)
}
}
+
+// The bugs keep coming. We forgot to send map subtypes before the map.
+
+type Bug1Elem struct {
+ Name string
+ Id int
+}
+
+type Bug1StructMap map[string]Bug1Elem
+
+func bug1EncDec(in Bug1StructMap, out *Bug1StructMap) os.Error {
+ return nil
+}
+
+func TestMapBug1(t *testing.T) {
+ in := make(Bug1StructMap)
+ in["val1"] = Bug1Elem{"elem1", 1}
+ in["val2"] = Bug1Elem{"elem2", 2}
+
+ b := new(bytes.Buffer)
+ enc := NewEncoder(b)
+ err := enc.Encode(in)
+ if err != nil {
+ t.Fatal("encode:", err)
+ }
+ dec := NewDecoder(b)
+ out := make(Bug1StructMap)
+ err = dec.Decode(&out)
+ if err != nil {
+ t.Fatal("decode:", err)
+ }
+ if !reflect.DeepEqual(in, out) {
+ t.Errorf("mismatch: %v %v", in, out)
+ }
+}
OpenPOWER on IntegriCloud