diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
commit | 9464a0c36318f8a801c07d6874bd0cea40f12504 (patch) | |
tree | f0178491c19d4f1ebc7b92eede86690998466480 /src/pkg/gob/codec_test.go | |
parent | ba9fda6068cfadd42db0b152fdca7e8b67aaf77d (diff) | |
parent | 5ff4c17907d5b19510a62e08fd8d3b11e62b431d (diff) | |
download | golang-9464a0c36318f8a801c07d6874bd0cea40f12504.tar.gz |
Merge commit 'upstream/60' into debian-sid
Diffstat (limited to 'src/pkg/gob/codec_test.go')
-rw-r--r-- | src/pkg/gob/codec_test.go | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/pkg/gob/codec_test.go b/src/pkg/gob/codec_test.go index da8e59c74..a5fb91cda 100644 --- a/src/pkg/gob/codec_test.go +++ b/src/pkg/gob/codec_test.go @@ -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 |