LEFT | RIGHT |
(no file at all) | |
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 "os" | 9 "os" |
10 "reflect" | 10 "reflect" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if err := checkValid(in, &scan); err != nil { | 131 if err := checkValid(in, &scan); err != nil { |
132 if !reflect.DeepEqual(err, tt.err) { | 132 if !reflect.DeepEqual(err, tt.err) { |
133 t.Errorf("#%d: checkValid: %#v", i, err) | 133 t.Errorf("#%d: checkValid: %#v", i, err) |
134 continue | 134 continue |
135 } | 135 } |
136 } | 136 } |
137 if tt.ptr == nil { | 137 if tt.ptr == nil { |
138 continue | 138 continue |
139 } | 139 } |
140 // v = new(right-type) | 140 // v = new(right-type) |
141 » » v := reflect.NewValue(tt.ptr) | 141 » » v := reflect.New(reflect.Typeof(tt.ptr).Elem()) |
142 » » v.Set(reflect.Zero(v.Type().Elem()).Addr()) | |
143 if err := Unmarshal([]byte(in), v.Interface()); !reflect.DeepEqu
al(err, tt.err) { | 142 if err := Unmarshal([]byte(in), v.Interface()); !reflect.DeepEqu
al(err, tt.err) { |
144 t.Errorf("#%d: %v want %v", i, err, tt.err) | 143 t.Errorf("#%d: %v want %v", i, err, tt.err) |
145 continue | 144 continue |
146 } | 145 } |
147 if !reflect.DeepEqual(v.Elem().Interface(), tt.out) { | 146 if !reflect.DeepEqual(v.Elem().Interface(), tt.out) { |
148 t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.E
lem().Interface(), tt.out) | 147 t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.E
lem().Interface(), tt.out) |
149 data, _ := Marshal(v.Elem().Interface()) | 148 data, _ := Marshal(v.Elem().Interface()) |
150 println(string(data)) | 149 println(string(data)) |
151 data, _ = Marshal(tt.out) | 150 data, _ = Marshal(tt.out) |
152 println(string(data)) | 151 println(string(data)) |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 }, | 531 }, |
533 "PSmall": null, | 532 "PSmall": null, |
534 "PPSmall": { | 533 "PPSmall": { |
535 "Tag": "tag31" | 534 "Tag": "tag31" |
536 }, | 535 }, |
537 "Interface": null, | 536 "Interface": null, |
538 "PInterface": 5.2 | 537 "PInterface": 5.2 |
539 }` | 538 }` |
540 | 539 |
541 var pallValueCompact = strings.Map(noSpace, pallValueIndent) | 540 var pallValueCompact = strings.Map(noSpace, pallValueIndent) |
LEFT | RIGHT |