diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-16 15:47:21 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-16 15:47:21 +0000 |
commit | 49b4e44b7d540fa846d353b10237848a67789cbf (patch) | |
tree | ea2b52e3c258d6b6d9356977c683c7f72a4a5fd5 /libgo/go/gob/codec_test.go | |
parent | 82ceb8f6a88a0193971f53e0571e017f2764f7d7 (diff) | |
download | ppe42-gcc-49b4e44b7d540fa846d353b10237848a67789cbf.tar.gz ppe42-gcc-49b4e44b7d540fa846d353b10237848a67789cbf.zip |
Update Go library to r60.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178910 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/gob/codec_test.go')
-rw-r--r-- | libgo/go/gob/codec_test.go | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/libgo/go/gob/codec_test.go b/libgo/go/gob/codec_test.go index 8961336cd34..a5fb91cda78 100644 --- a/libgo/go/gob/codec_test.go +++ b/libgo/go/gob/codec_test.go @@ -330,7 +330,7 @@ func newDecodeStateFromData(data []byte) *decoderState { // Test instruction execution for decoding. // Do not run the machine yet; instead do individual instructions crafted by hand. func TestScalarDecInstructions(t *testing.T) { - ovfl := os.ErrorString("overflow") + ovfl := os.NewError("overflow") // bool { @@ -573,30 +573,32 @@ func TestEndToEnd(t *testing.T) { s1 := "string1" s2 := "string2" type T1 struct { - A, B, C int - M map[string]*float64 - N *[3]float64 - Strs *[2]string - Int64s *[]int64 - RI complex64 - S string - Y []byte - T *T2 + A, B, C int + M map[string]*float64 + EmptyMap map[string]int // to check that we receive a non-nil map. + N *[3]float64 + Strs *[2]string + Int64s *[]int64 + RI complex64 + S string + Y []byte + T *T2 } pi := 3.14159 e := 2.71828 t1 := &T1{ - A: 17, - B: 18, - C: -5, - M: map[string]*float64{"pi": &pi, "e": &e}, - N: &[3]float64{1.5, 2.5, 3.5}, - Strs: &[2]string{s1, s2}, - Int64s: &[]int64{77, 89, 123412342134}, - RI: 17 - 23i, - S: "Now is the time", - Y: []byte("hello, sailor"), - T: &T2{"this is T2"}, + A: 17, + B: 18, + C: -5, + M: map[string]*float64{"pi": &pi, "e": &e}, + EmptyMap: make(map[string]int), + N: &[3]float64{1.5, 2.5, 3.5}, + Strs: &[2]string{s1, s2}, + Int64s: &[]int64{77, 89, 123412342134}, + RI: 17 - 23i, + S: "Now is the time", + Y: []byte("hello, sailor"), + T: &T2{"this is T2"}, } b := new(bytes.Buffer) err := NewEncoder(b).Encode(t1) @@ -611,6 +613,13 @@ func TestEndToEnd(t *testing.T) { if !reflect.DeepEqual(t1, &_t1) { t.Errorf("encode expected %v got %v", *t1, _t1) } + // Be absolutely sure the received map is non-nil. + if t1.EmptyMap == nil { + t.Errorf("nil map sent") + } + if _t1.EmptyMap == nil { + t.Errorf("nil map received") + } } func TestOverflow(t *testing.T) { @@ -782,7 +791,6 @@ func TestOverflow(t *testing.T) { } } - func TestNesting(t *testing.T) { type RT struct { A string @@ -980,7 +988,6 @@ func TestIgnoredFields(t *testing.T) { } } - func TestBadRecursiveType(t *testing.T) { type Rec ***Rec var rec Rec |