OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package json | 5 package json |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "image" | 10 "image" |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 if err != nil { | 993 if err != nil { |
994 t.Errorf("Unmarshal of null values failed: %v", err) | 994 t.Errorf("Unmarshal of null values failed: %v", err) |
995 } | 995 } |
996 if !nulls.Bool || nulls.Int != 2 || nulls.Int8 != 3 || nulls.Int16 != 4
|| nulls.Int32 != 5 || nulls.Int64 != 6 || | 996 if !nulls.Bool || nulls.Int != 2 || nulls.Int8 != 3 || nulls.Int16 != 4
|| nulls.Int32 != 5 || nulls.Int64 != 6 || |
997 nulls.Uint != 7 || nulls.Uint8 != 8 || nulls.Uint16 != 9 || null
s.Uint32 != 10 || nulls.Uint64 != 11 || | 997 nulls.Uint != 7 || nulls.Uint8 != 8 || nulls.Uint16 != 9 || null
s.Uint32 != 10 || nulls.Uint64 != 11 || |
998 nulls.Float32 != 12.1 || nulls.Float64 != 13.1 || nulls.String !
= "14" { | 998 nulls.Float32 != 12.1 || nulls.Float64 != 13.1 || nulls.String !
= "14" { |
999 | 999 |
1000 t.Errorf("Unmarshal of null values affected primitives") | 1000 t.Errorf("Unmarshal of null values affected primitives") |
1001 } | 1001 } |
1002 } | 1002 } |
| 1003 |
| 1004 func TestStringKind(t *testing.T) { |
| 1005 type stringKind string |
| 1006 type aMap map[stringKind]int |
| 1007 |
| 1008 var m1, m2 map[stringKind]int |
| 1009 m1 = map[stringKind]int{ |
| 1010 "foo": 42, |
| 1011 } |
| 1012 |
| 1013 data, err := Marshal(m1) |
| 1014 if err != nil { |
| 1015 t.Errorf("Unexpected error marshalling: %v", err) |
| 1016 } |
| 1017 |
| 1018 err = Unmarshal(data, &m2) |
| 1019 if err != nil { |
| 1020 t.Errorf("Unexpected error unmarshalling: %v", err) |
| 1021 } |
| 1022 |
| 1023 if !reflect.DeepEqual(m1, m2) { |
| 1024 t.Error("Items should be equal after encoding and then decoding"
) |
| 1025 } |
| 1026 |
| 1027 } |
OLD | NEW |