Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(553)

Side by Side Diff: src/pkg/encoding/json/decode_test.go

Issue 6943047: code review 6943047: encoding/json: encode map key is of string kind, decode... (Closed)
Patch Set: diff -r a298f2d529ec https://code.google.com/p/go/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/encoding/json/decode.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/pkg/encoding/json/decode.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b