LEFT | RIGHT |
1 package goyaml_test | 1 package goyaml_test |
2 | 2 |
3 import ( | 3 import ( |
4 . "launchpad.net/gocheck" | 4 . "launchpad.net/gocheck" |
5 "launchpad.net/goyaml" | 5 "launchpad.net/goyaml" |
6 "math" | 6 "math" |
7 "reflect" | 7 "reflect" |
8 ) | 8 ) |
9 | 9 |
10 var unmarshalIntTest = 123 | 10 var unmarshalIntTest = 123 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Map inside interface with no type hints. | 78 // Map inside interface with no type hints. |
79 {"a: {b: c}", | 79 {"a: {b: c}", |
80 map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"
}}}, | 80 map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"
}}}, |
81 | 81 |
82 // Structs and type conversions. | 82 // Structs and type conversions. |
83 {"hello: world", &struct{ Hello string }{"world"}}, | 83 {"hello: world", &struct{ Hello string }{"world"}}, |
84 {"a: {b: c}", &struct{ A struct{ B string } }{struct{ B string }{"c"}}}, | 84 {"a: {b: c}", &struct{ A struct{ B string } }{struct{ B string }{"c"}}}, |
85 {"a: {b: c}", &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}
}, | 85 {"a: {b: c}", &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}
}, |
86 {"a: {b: c}", &struct{ A map[string]string }{map[string]string{"b": "c"}
}}, | 86 {"a: {b: c}", &struct{ A map[string]string }{map[string]string{"b": "c"}
}}, |
| 87 {"a: {b: c}", &struct{ A *map[string]string }{&map[string]string{"b": "c
"}}}, |
87 {"a: 1", &struct{ A int }{1}}, | 88 {"a: 1", &struct{ A int }{1}}, |
88 {"a: [1, 2]", &struct{ A []int }{[]int{1, 2}}}, | 89 {"a: [1, 2]", &struct{ A []int }{[]int{1, 2}}}, |
89 {"a: 1", &struct{ B int }{0}}, | 90 {"a: 1", &struct{ B int }{0}}, |
90 {"a: 1", &struct { | 91 {"a: 1", &struct { |
91 B int "a" | 92 B int "a" |
92 }{1}}, | 93 }{1}}, |
93 {"a: y", &struct{ A bool }{true}}, | 94 {"a: y", &struct{ A bool }{true}}, |
94 | 95 |
95 // Some cross type conversions | 96 // Some cross type conversions |
96 {"v: 42", map[string]uint{"v": 42}}, | 97 {"v: 42", map[string]uint{"v": 42}}, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 err := goyaml.Unmarshal([]byte(data), m) | 226 err := goyaml.Unmarshal([]byte(data), m) |
226 c.Assert(err, IsNil) | 227 c.Assert(err, IsNil) |
227 c.Assert(m["abc"], NotNil) | 228 c.Assert(m["abc"], NotNil) |
228 c.Assert(m["def"], IsNil) | 229 c.Assert(m["def"], IsNil) |
229 c.Assert(m["ghi"], NotNil) | 230 c.Assert(m["ghi"], NotNil) |
230 c.Assert(m["jkl"], IsNil) | 231 c.Assert(m["jkl"], IsNil) |
231 | 232 |
232 c.Assert(m["abc"].value, Equals, 1) | 233 c.Assert(m["abc"].value, Equals, 1) |
233 c.Assert(m["ghi"].value, Equals, 3) | 234 c.Assert(m["ghi"].value, Equals, 3) |
234 } | 235 } |
LEFT | RIGHT |