OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 xml | 5 package xml |
6 | 6 |
7 import ( | 7 import ( |
8 "reflect" | 8 "reflect" |
9 "testing" | 9 "testing" |
10 ) | 10 ) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 var pathTests = []interface{}{ | 282 var pathTests = []interface{}{ |
283 &PathTestA{Items: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}
, | 283 &PathTestA{Items: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}
, |
284 &PathTestB{Other: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}
, | 284 &PathTestB{Other: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}
, |
285 &PathTestC{Values1: []string{"A", "C", "D"}, Values2: []string{"B"}, Bef
ore: "1", After: "2"}, | 285 &PathTestC{Values1: []string{"A", "C", "D"}, Values2: []string{"B"}, Bef
ore: "1", After: "2"}, |
286 &PathTestD{Other: PathTestSet{Item1: []PathTestItem{{"A"}, {"D"}}}, Befo
re: "1", After: "2"}, | 286 &PathTestD{Other: PathTestSet{Item1: []PathTestItem{{"A"}, {"D"}}}, Befo
re: "1", After: "2"}, |
287 } | 287 } |
288 | 288 |
289 func TestUnmarshalPaths(t *testing.T) { | 289 func TestUnmarshalPaths(t *testing.T) { |
290 for _, pt := range pathTests { | 290 for _, pt := range pathTests { |
291 p := reflect.MakeZero(reflect.NewValue(pt).Type()).(*reflect.Ptr
Value) | 291 p := reflect.MakeZero(reflect.NewValue(pt).Type()).(*reflect.Ptr
Value) |
292 » » p.PointTo(reflect.MakeZero(p.Type().(*reflect.PtrType).Elem())) | 292 » » p.PointTo(reflect.MakeZero(p.Type().Elem())) |
293 v := p.Interface() | 293 v := p.Interface() |
294 if err := Unmarshal(StringReader(pathTestString), v); err != nil
{ | 294 if err := Unmarshal(StringReader(pathTestString), v); err != nil
{ |
295 t.Fatalf("Unmarshal: %s", err) | 295 t.Fatalf("Unmarshal: %s", err) |
296 } | 296 } |
297 if !reflect.DeepEqual(v, pt) { | 297 if !reflect.DeepEqual(v, pt) { |
298 t.Fatalf("have %#v\nwant %#v", v, pt) | 298 t.Fatalf("have %#v\nwant %#v", v, pt) |
299 } | 299 } |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
(...skipping 17 matching lines...) Expand all Loading... |
320 } | 320 } |
321 | 321 |
322 func TestUnmarshalBadPaths(t *testing.T) { | 322 func TestUnmarshalBadPaths(t *testing.T) { |
323 for _, tt := range badPathTests { | 323 for _, tt := range badPathTests { |
324 err := Unmarshal(StringReader(pathTestString), tt.v) | 324 err := Unmarshal(StringReader(pathTestString), tt.v) |
325 if !reflect.DeepEqual(err, tt.e) { | 325 if !reflect.DeepEqual(err, tt.e) { |
326 t.Fatalf("Unmarshal with %#v didn't fail properly: %#v",
tt.v, err) | 326 t.Fatalf("Unmarshal with %#v didn't fail properly: %#v",
tt.v, err) |
327 } | 327 } |
328 } | 328 } |
329 } | 329 } |
OLD | NEW |