Debian Codegraph @

decode_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package yaml_testscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/
2
3 import (
4 "errorsscip-go gomod github.com/golang/go/src go1.15 errors/"
5 "ioscip-go gomod github.com/golang/go/src go1.15 io/"
6 "mathscip-go gomod github.com/golang/go/src go1.15 math/"
7 "reflectscip-go gomod github.com/golang/go/src go1.15 reflect/"
8 "stringsscip-go gomod github.com/golang/go/src go1.15 strings/"
9 "testingscip-go gomod github.com/golang/go/src go1.15 testing/"
10 "timescip-go gomod github.com/golang/go/src go1.15 time/"
11
12 "go.yaml.in/yaml/v2scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/"
13 )
14
15 var unmarshalIntTestscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalIntTest. = 123
16
17 var unmarshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests. = []struct {
18 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data. string
19 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value. interface{}
20 }{
21 {
22 "",
23 (*struct{})(nil),
24 },
25 {
26 "{}", &struct{}{},
27 }, {
28 "v: hi",
29 map[string]string{"v": "hi"},
30 }, {
31 "v: hi", map[string]interface{}{"v": "hi"},
32 }, {
33 "v: true",
34 map[string]string{"v": "true"},
35 }, {
36 "v: true",
37 map[string]interface{}{"v": true},
38 }, {
39 "v: 10",
40 map[string]interface{}{"v": 10},
41 }, {
42 "v: 0b10",
43 map[string]interface{}{"v": 2},
44 }, {
45 "v: 0xA",
46 map[string]interface{}{"v": 10},
47 }, {
48 "v: 4294967296",
49 map[string]int64{"v": 4294967296},
50 }, {
51 "v: 0.1",
52 map[string]interface{}{"v": 0.1},
53 }, {
54 "v: .1",
55 map[string]interface{}{"v": 0.1},
56 }, {
57 "v: .Inf",
58 map[string]interface{}{"v": mathscip-go gomod github.com/golang/go/src go1.15 math/.Infscip-go gomod github.com/golang/go/src go1.15 math/Inf().(+1)},
59 }, {
60 "v: -.Inf",
61 map[string]interface{}{"v": mathscip-go gomod github.com/golang/go/src go1.15 math/.Infscip-go gomod github.com/golang/go/src go1.15 math/Inf().(-1)},
62 }, {
63 "v: -10",
64 map[string]interface{}{"v": -10},
65 }, {
66 "v: -.1",
67 map[string]interface{}{"v": -0.1},
68 },
69
70 // Simple values.
71 {
72 "123",
73 &unmarshalIntTestscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalIntTest.,
74 },
75
76 // Floats from spec
77 {
78 "canonical: 6.8523e+5",
79 map[string]interface{}{"canonical": 6.8523e+5},
80 }, {
81 "expo: 685.230_15e+03",
82 map[string]interface{}{"expo": 685.23015e+03},
83 }, {
84 "fixed: 685_230.15",
85 map[string]interface{}{"fixed": 685230.15},
86 }, {
87 "neginf: -.inf",
88 map[string]interface{}{"neginf": mathscip-go gomod github.com/golang/go/src go1.15 math/.Infscip-go gomod github.com/golang/go/src go1.15 math/Inf().(-1)},
89 }, {
90 "fixed: 685_230.15",
91 map[string]float64{"fixed": 685230.15},
92 },
93 //{"sexa: 190:20:30.15", map[string]interface{}{"sexa": 0}}, // Unsupported
94 //{"notanum: .NaN", map[string]interface{}{"notanum": math.NaN()}}, // Equality of NaN fails.
95
96 // Bools from spec
97 {
98 "canonical: y",
99 map[string]interface{}{"canonical": true},
100 }, {
101 "answer: NO",
102 map[string]interface{}{"answer": false},
103 }, {
104 "logical: True",
105 map[string]interface{}{"logical": true},
106 }, {
107 "option: on",
108 map[string]interface{}{"option": true},
109 }, {
110 "option: on",
111 map[string]bool{"option": true},
112 },
113 // Ints from spec
114 {
115 "canonical: 685230",
116 map[string]interface{}{"canonical": 685230},
117 }, {
118 "decimal: +685_230",
119 map[string]interface{}{"decimal": 685230},
120 }, {
121 "octal: 02472256",
122 map[string]interface{}{"octal": 685230},
123 }, {
124 "hexa: 0x_0A_74_AE",
125 map[string]interface{}{"hexa": 685230},
126 }, {
127 "bin: 0b1010_0111_0100_1010_1110",
128 map[string]interface{}{"bin": 685230},
129 }, {
130 "bin: -0b101010",
131 map[string]interface{}{"bin": -42},
132 }, {
133 "decimal: +685_230",
134 map[string]int{"decimal": 685230},
135 },
136
137 //{"sexa: 190:20:30", map[string]interface{}{"sexa": 0}}, // Unsupported
138
139 // Nulls from spec
140 {
141 "empty:",
142 map[string]interface{}{"empty": nil},
143 }, {
144 "canonical: ~",
145 map[string]interface{}{"canonical": nil},
146 }, {
147 "english: null",
148 map[string]interface{}{"english": nil},
149 }, {
150 "~: null key",
151 map[interface{}]string{nil: "null key"},
152 }, {
153 "empty:",
154 map[string]*bool{"empty": nil},
155 },
156
157 // Flow sequence
158 {
159 "seq: [A,B]",
160 map[string]interface{}{"seq": []interface{}{"A", "B"}},
161 }, {
162 "seq: [A,B,C,]",
163 map[string][]string{"seq": []string{"A", "B", "C"}},
164 }, {
165 "seq: [A,1,C]",
166 map[string][]string{"seq": []string{"A", "1", "C"}},
167 }, {
168 "seq: [A,1,C]",
169 map[string][]int{"seq": []int{1}},
170 }, {
171 "seq: [A,1,C]",
172 map[string]interface{}{"seq": []interface{}{"A", 1, "C"}},
173 },
174 // Block sequence
175 {
176 "seq:\n - A\n - B",
177 map[string]interface{}{"seq": []interface{}{"A", "B"}},
178 }, {
179 "seq:\n - A\n - B\n - C",
180 map[string][]string{"seq": []string{"A", "B", "C"}},
181 }, {
182 "seq:\n - A\n - 1\n - C",
183 map[string][]string{"seq": []string{"A", "1", "C"}},
184 }, {
185 "seq:\n - A\n - 1\n - C",
186 map[string][]int{"seq": []int{1}},
187 }, {
188 "seq:\n - A\n - 1\n - C",
189 map[string]interface{}{"seq": []interface{}{"A", 1, "C"}},
190 },
191
192 // Literal block scalar
193 {
194 "scalar: | # Comment\n\n literal\n\n \ttext\n\n",
195 map[string]string{"scalar": "\nliteral\n\n\ttext\n"},
196 },
197
198 // Folded block scalar
199 {
200 "scalar: > # Comment\n\n folded\n line\n \n next\n line\n * one\n * two\n\n last\n line\n\n",
201 map[string]string{"scalar": "\nfolded line\nnext line\n * one\n * two\n\nlast line\n"},
202 },
203
204 // Map inside interface with no type hints.
205 {
206 "a: {b: c}",
207 map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": "c"}},
208 },
209
210 // Structs and type conversions.
211 {
212 "hello: world",
213 &struct{ Helloscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:Hello. string }{"world"},
214 }, {
215 "a: {b: c}",
216 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:$anon_6f306943eb750927#B. string } }{struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. string }{"c"}},
217 }, {
218 "a: {b: c}",
219 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. *struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:$anon_6f306943eb750927#B. string } }{&struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. string }{"c"}},
220 }, {
221 "a: {b: c}",
222 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. map[string]string }{map[string]string{"b": "c"}},
223 }, {
224 "a: {b: c}",
225 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. *map[string]string }{&map[string]string{"b": "c"}},
226 }, {
227 "a:",
228 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. map[string]string }{},
229 }, {
230 "a: 1",
231 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. int }{1},
232 }, {
233 "a: 1",
234 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. float64 }{1},
235 }, {
236 "a: 1.0",
237 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. int }{1},
238 }, {
239 "a: 1.0",
240 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. uint }{1},
241 }, {
242 "a: [1, 2]",
243 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. []int }{[]int{1, 2}},
244 }, {
245 "a: [1, 2]",
246 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. [2]int }{[2]int{1, 2}},
247 }, {
248 "a: 1",
249 &struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. int }{0},
250 }, {
251 "a: 1",
252 &struct {
253 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. int "a"
254 }{1},
255 }, {
256 "a: y",
257 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. bool }{true},
258 },
259
260 // Some cross type conversions
261 {
262 "v: 42",
263 map[string]uint{"v": 42},
264 }, {
265 "v: -42",
266 map[string]uint{},
267 }, {
268 "v: 4294967296",
269 map[string]uint64{"v": 4294967296},
270 }, {
271 "v: -4294967296",
272 map[string]uint64{},
273 },
274
275 // int
276 {
277 "int_max: 2147483647",
278 map[string]int{"int_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxInt32scip-go gomod github.com/golang/go/src go1.15 math/MaxInt32.},
279 },
280 {
281 "int_min: -2147483648",
282 map[string]int{"int_min": mathscip-go gomod github.com/golang/go/src go1.15 math/.MinInt32scip-go gomod github.com/golang/go/src go1.15 math/MinInt32.},
283 },
284 {
285 "int_overflow: 9223372036854775808", // math.MaxInt64 + 1
286 map[string]int{},
287 },
288
289 // int64
290 {
291 "int64_max: 9223372036854775807",
292 map[string]int64{"int64_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.15 math/MaxInt64.},
293 },
294 {
295 "int64_max_base2: 0b111111111111111111111111111111111111111111111111111111111111111",
296 map[string]int64{"int64_max_base2": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.15 math/MaxInt64.},
297 },
298 {
299 "int64_min: -9223372036854775808",
300 map[string]int64{"int64_min": mathscip-go gomod github.com/golang/go/src go1.15 math/.MinInt64scip-go gomod github.com/golang/go/src go1.15 math/MinInt64.},
301 },
•302 {
303 "int64_min_base2: -0b1000000000000000000000000000000000000000000000000000000000000000",
304 map[string]int64{"int64_min_base2": mathscip-go gomod github.com/golang/go/src go1.15 math/.MinInt64scip-go gomod github.com/golang/go/src go1.15 math/MinInt64.},
305 },
306 {
307 "int64_neg_base2: -0b111111111111111111111111111111111111111111111111111111111111111",
308 map[string]int64{"int64_neg_base2": -mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.15 math/MaxInt64.},
309 },
310 {
311 "int64_overflow: 9223372036854775808", // math.MaxInt64 + 1
312 map[string]int64{},
313 },
314
315 // uint
316 {
317 "uint_min: 0",
318 map[string]uint{"uint_min": 0},
319 },
320 {
321 "uint_max: 4294967295",
322 map[string]uint{"uint_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint32scip-go gomod github.com/golang/go/src go1.15 math/MaxUint32.},
323 },
324 {
325 "uint_underflow: -1",
326 map[string]uint{},
327 },
328
329 // uint64
330 {
331 "uint64_min: 0",
332 map[string]uint{"uint64_min": 0},
333 },
334 {
335 "uint64_max: 18446744073709551615",
336 map[string]uint64{"uint64_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64.},
337 },
338 {
339 "uint64_max_base2: 0b1111111111111111111111111111111111111111111111111111111111111111",
340 map[string]uint64{"uint64_max_base2": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64.},
341 },
342 {
343 "uint64_maxint64: 9223372036854775807",
344 map[string]uint64{"uint64_maxint64": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.15 math/MaxInt64.},
345 },
346 {
347 "uint64_underflow: -1",
348 map[string]uint64{},
349 },
350
351 // float32
352 {
353 "float32_max: 3.40282346638528859811704183484516925440e+38",
354 map[string]float32{"float32_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxFloat32scip-go gomod github.com/golang/go/src go1.15 math/MaxFloat32.},
355 },
356 {
357 "float32_nonzero: 1.401298464324817070923729583289916131280e-45",
358 map[string]float32{"float32_nonzero": mathscip-go gomod github.com/golang/go/src go1.15 math/.SmallestNonzeroFloat32scip-go gomod github.com/golang/go/src go1.15 math/SmallestNonzeroFloat32.},
359 },
360 {
361 "float32_maxuint64: 18446744073709551615",
362 map[string]float32{"float32_maxuint64": float32(mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64.)},
363 },
364 {
365 "float32_maxuint64+1: 18446744073709551616",
366 map[string]float32{"float32_maxuint64+1": float32(mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64. + 1)},
367 },
368
369 // float64
370 {
371 "float64_max: 1.797693134862315708145274237317043567981e+308",
372 map[string]float64{"float64_max": mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxFloat64scip-go gomod github.com/golang/go/src go1.15 math/MaxFloat64.},
373 },
374 {
375 "float64_nonzero: 4.940656458412465441765687928682213723651e-324",
376 map[string]float64{"float64_nonzero": mathscip-go gomod github.com/golang/go/src go1.15 math/.SmallestNonzeroFloat64scip-go gomod github.com/golang/go/src go1.15 math/SmallestNonzeroFloat64.},
377 },
378 {
379 "float64_maxuint64: 18446744073709551615",
380 map[string]float64{"float64_maxuint64": float64(mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64.)},
381 },
382 {
383 "float64_maxuint64+1: 18446744073709551616",
384 map[string]float64{"float64_maxuint64+1": float64(mathscip-go gomod github.com/golang/go/src go1.15 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.15 math/MaxUint64. + 1)},
385 },
386
387 // Overflow cases.
388 {
389 "v: 4294967297",
390 map[string]int32{},
391 }, {
392 "v: 128",
393 map[string]int8{},
394 },
395
396 // Quoted values.
397 {
398 "'1': '\"2\"'",
399 map[interface{}]interface{}{"1": "\"2\""},
400 }, {
401 "v:\n- A\n- 'B\n\n C'\n",
402 map[string][]string{"v": []string{"A", "B\nC"}},
403 },
404
405 // Explicit tags.
406 {
407 "v: !!float '1.1'",
408 map[string]interface{}{"v": 1.1},
409 }, {
410 "v: !!float 0",
411 map[string]interface{}{"v": float64(0)},
412 }, {
413 "v: !!float -1",
414 map[string]interface{}{"v": float64(-1)},
415 }, {
416 "v: !!null ''",
417 map[string]interface{}{"v": nil},
418 }, {
419 "%TAG !y! tag:yaml.org,2002:\n---\nv: !y!int '1'",
420 map[string]interface{}{"v": 1},
421 },
422
423 // Non-specific tag (Issue #75)
424 {
425 "v: ! test",
426 map[string]interface{}{"v": "test"},
427 },
428
429 // Anchors and aliases.
430 {
431 "a: &x 1\nb: &y 2\nc: *x\nd: *y\n",
432 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A., Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B., Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:C., Dscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:D. int }{1, 2, 1, 2},
433 }, {
434 "a: &a {c: 1}\nb: *a",
435 &struct {
436 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A., Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. struct {
437 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:$anon_c431074b2d0645df#C. int
438 }
439 }{struct{ Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:C. int }{1}, struct{ Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:C. int }{1}},
440 }, {
441 "a: &a [1, 2]\nb: *a",
442 &struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. []int }{[]int{1, 2}},
443 },
444
445 // Bug #1133337
446 {
447 "foo: ''",
448 map[string]*string{"foo": new(string)},
449 }, {
450 "foo: null",
451 map[string]*string{"foo": nil},
452 }, {
453 "foo: null",
454 map[string]string{"foo": ""},
455 }, {
456 "foo: null",
457 map[string]interface{}{"foo": nil},
458 },
459
460 // Support for ~
461 {
462 "foo: ~",
463 map[string]*string{"foo": nil},
464 }, {
465 "foo: ~",
466 map[string]string{"foo": ""},
467 }, {
468 "foo: ~",
469 map[string]interface{}{"foo": nil},
470 },
471
472 // Ignored field
473 {
474 "a: 1\nb: 2\n",
475 &struct {
476 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. int
477 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. int "-"
478 }{1, 0},
479 },
480
481 // Bug #1191981
482 {
483 "" +
484 "%YAML 1.1\n" +
485 "--- !!str\n" +
486 `"Generic line break (no glyph)\n\` + "\n" +
487 ` Generic line break (glyphed)\n\` + "\n" +
488 ` Line separator\u2028\` + "\n" +
489 ` Paragraph separator\u2029"` + "\n",
490 "" +
491 "Generic line break (no glyph)\n" +
492 "Generic line break (glyphed)\n" +
493 "Line separator\u2028Paragraph separator\u2029",
494 },
495
496 // Struct inlining
497 {
498 "a: 1\nb: 2\nc: 3\n",
499 &struct {
500 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. int
501 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:C. inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB# `yaml:",inline"`
502 }{1, inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#{2, inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#{3}}},
503 },
504
505 // Map inlining
506 {
507 "a: 1\nb: 2\nc: 3\n",
508 &struct {
509 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. int
510 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:C. map[string]int `yaml:",inline"`
511 }{1, map[string]int{"b": 2, "c": 3}},
512 },
513
514 // bug 1243827
515 {
516 "a: -b_c",
517 map[string]interface{}{"a": "-b_c"},
518 },
519 {
520 "a: +b_c",
521 map[string]interface{}{"a": "+b_c"},
522 },
523 {
524 "a: 50cent_of_dollar",
525 map[string]interface{}{"a": "50cent_of_dollar"},
526 },
527
528 // issue #295 (allow scalars with colons in flow mappings and sequences)
529 {
530 "a: {b: https://github.com/go-yaml/yaml}",
531 map[string]interface{}{"a": map[interface{}]interface{}{
532 "b": "https://github.com/go-yaml/yaml",
533 }},
534 },
535 {
536 "a: [https://github.com/go-yaml/yaml]",
537 map[string]interface{}{"a": []interface{}{"https://github.com/go-yaml/yaml"}},
538 },
539
540 // Duration
541 {
542 "a: 3s",
543 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#{"a": 3 * timescip-go gomod github.com/golang/go/src go1.15 time/.Secondscip-go gomod github.com/golang/go/src go1.15 time/Second.},
544 },
545
546 // Issue #24.
547 {
548 "a: <foo>",
549 map[string]string{"a": "<foo>"},
550 },
551
552 // Base 60 floats are obsolete and unsupported.
553 {
554 "a: 1:1\n",
555 map[string]string{"a": "1:1"},
556 },
557
558 // Binary data.
559 {
560 "a: !!binary gIGC\n",
561 map[string]string{"a": "\x80\x81\x82"},
562 }, {
563 "a: !!binary |\n " + stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Repeatscip-go gomod github.com/golang/go/src go1.15 strings/Repeat().("kJCQ", 17) + "kJ\n CQ\n",
564 map[string]string{"a": stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Repeatscip-go gomod github.com/golang/go/src go1.15 strings/Repeat().("\x90", 54)},
565 }, {
566 "a: !!binary |\n " + stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Repeatscip-go gomod github.com/golang/go/src go1.15 strings/Repeat().("A", 70) + "\n ==\n",
567 map[string]string{"a": stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Repeatscip-go gomod github.com/golang/go/src go1.15 strings/Repeat().("\x00", 52)},
568 },
569
570 // Ordered maps.
571 {
572 "{b: 2, a: 1, d: 4, c: 3, sub: {e: 5}}",
573 &yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.MapSlicescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/MapSlice#{{"b", 2}, {"a", 1}, {"d", 4}, {"c", 3}, {"sub", yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.MapSlicescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/MapSlice#{{"e", 5}}}},
574 },
575
576 // Issue #39.
577 {
578 "a:\n b:\n c: d\n",
579 map[string]struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:B. interface{} }{"a": {map[interface{}]interface{}{"c": "d"}}},
580 },
581
582 // Custom map type.
583 {
584 "a: {b: c}",
585 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"a": Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"b": "c"}},
586 },
587
588 // Support encoding.TextUnmarshaler.
589 {
590 "a: 1.2.3.4\n",
591 map[string]textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#{"a": textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#{Sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#S.: "1.2.3.4"}},
592 },
593 {
594 "a: 2015-02-24T18:19:39Z\n",
595 map[string]textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#{"a": textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#{"2015-02-24T18:19:39Z"}},
596 },
597
598 // Timestamps
599 {
600 // Date only.
601 "a: 2015-01-01\n",
602 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 1, 1, 0, 0, 0, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
603 },
604 {
605 // RFC3339
606 "a: 2015-02-24T18:19:39.12Z\n",
607 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 24, 18, 19, 39, .12e9, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
608 },
609 {
610 // RFC3339 with short dates.
611 "a: 2015-2-3T3:4:5Z",
612 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 3, 3, 4, 5, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
613 },
614 {
615 // ISO8601 lower case t
616 "a: 2015-02-24t18:19:39Z\n",
617 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 24, 18, 19, 39, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
618 },
619 {
620 // space separate, no time zone
621 "a: 2015-02-24 18:19:39\n",
622 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 24, 18, 19, 39, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
623 },
624 // Some cases not currently handled. Uncomment these when
625 // the code is fixed.
626 // {
627 // // space separated with time zone
628 // "a: 2001-12-14 21:59:43.10 -5",
629 // map[string]interface{}{"a": time.Date(2001, 12, 14, 21, 59, 43, .1e9, time.UTC)},
630 // },
631 // {
632 // // arbitrary whitespace between fields
633 // "a: 2001-12-14 \t\t \t21:59:43.10 \t Z",
634 // map[string]interface{}{"a": time.Date(2001, 12, 14, 21, 59, 43, .1e9, time.UTC)},
635 // },
636 {
637 // explicit string tag
638 "a: !!str 2015-01-01",
639 map[string]interface{}{"a": "2015-01-01"},
640 },
641 {
642 // explicit timestamp tag on quoted string
643 "a: !!timestamp \"2015-01-01\"",
644 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 1, 1, 0, 0, 0, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
645 },
646 {
647 // explicit timestamp tag on unquoted string
648 "a: !!timestamp 2015-01-01",
649 map[string]timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{"a": timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 1, 1, 0, 0, 0, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)},
650 },
651 {
652 // quoted string that's a valid timestamp
653 "a: \"2015-01-01\"",
654 map[string]interface{}{"a": "2015-01-01"},
655 },
656 {
657 // explicit timestamp tag into interface.
658 "a: !!timestamp \"2015-01-01\"",
659 map[string]interface{}{"a": "2015-01-01"},
660 },
661 {
662 // implicit timestamp tag into interface.
663 "a: 2015-01-01",
664 map[string]interface{}{"a": "2015-01-01"},
665 },
666
667 // Encode empty lists as zero-length slices.
668 {
669 "a: []",
670 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. []int }{[]int{}},
671 },
672
673 // UTF-16-LE
674 {
675 "\xff\xfe\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00\n\x00",
676 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"ñoño": "very yes"},
677 },
678 // UTF-16-LE with surrogate.
679 {
680 "\xff\xfe\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00 \x00=\xd8\xd4\xdf\n\x00",
681 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"ñoño": "very yes 🟔"},
682 },
683
684 // UTF-16-BE
685 {
686 "\xfe\xff\x00\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00\n",
687 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"ñoño": "very yes"},
688 },
689 // UTF-16-BE with surrogate.
690 {
691 "\xfe\xff\x00\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00 \xd8=\xdf\xd4\x00\n",
692 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"ñoño": "very yes 🟔"},
693 },
694
695 // This *is* in fact a float number, per the spec. #171 was a mistake.
696 {
697 "a: 123456e1\n",
698 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"a": 123456e1},
699 }, {
700 "a: 123456E1\n",
701 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"a": 123456E1},
702 },
703 // yaml-test-suite 3GZX: Spec Example 7.1. Alias Nodes
704 {
705 "First occurrence: &anchor Foo\nSecond occurrence: *anchor\nOverride anchor: &anchor Bar\nReuse anchor: *anchor\n",
706 map[interface{}]interface{}{
707 "Reuse anchor": "Bar",
708 "First occurrence": "Foo",
709 "Second occurrence": "Foo",
710 "Override anchor": "Bar",
711 },
712 },
713 // Single document with garbage following it.
714 {
715 "---\nhello\n...\n}not yaml",
716 "hello",
717 },
718 {
719 "a: 5\n",
720 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT# }{"5"},
721 },
722 {
723 "a: 5.5\n",
724 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:A. jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT# }{"5.5"},
725 },
726 {
727 `
728 a:
729 b
730 b:
731 ? a
732 : a`,
733 &Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{"a": "b",
734 "b": Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M#{
735 "a": "a",
736 }},
737 },
738 }
739
740 type Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/M# map[interface{}]interface{}
741
742 type inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB# struct {
743 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#B. int
744 inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#inlineC. `yaml:",inline"`
745 }
746
747 type inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC# struct {
748 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#C. int
749 }
750
751 func TestUnmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshal().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
752 for i, item := range unmarshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests. {
753 t.Logfscip-go gomod github.com/golang/go/src go1.15 testing/common#Logf().("test %d: %q", i, item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data.)
754 typ := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value.).Typescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Type().()
755 value := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Newscip-go gomod github.com/golang/go/src go1.15 reflect/New().(typ)
756 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data.), value.Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().())
757 if _, ok := err.(*yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.TypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/TypeError#); !ok {
758 if err != nil {
759 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
760 }
761 }
762 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value.) {
763 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %#v, want %#v (error: %v)", value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value., err)
764 }
765 }
766 }
767
768 // TODO(v3): This test should also work when unmarshaling onto an interface{}.
769 func TestUnmarshalFullTimestampscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalFullTimestamp().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
770 // Full timestamp in same format as encoded. This is confirmed to be
771 // properly decoded by Python as a timestamp as well.
772 var str = "2015-02-24T18:19:39.123456789-03:00"
773 var tm timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#
774 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(str), &tm)
775 if err != nil {
776 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
777 }
778 expected := timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 24, 18, 19, 39, 123456789, tm.Locationscip-go gomod github.com/golang/go/src go1.15 time/Time#Location().())
779 if !tm.Equalscip-go gomod github.com/golang/go/src go1.15 time/Time#Equal().(expected) || tm.Locationscip-go gomod github.com/golang/go/src go1.15 time/Time#Location().().Stringscip-go gomod github.com/golang/go/src go1.15 time/Location#String().() != expected.Locationscip-go gomod github.com/golang/go/src go1.15 time/Time#Location().().Stringscip-go gomod github.com/golang/go/src go1.15 time/Location#String().() {
780 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", tm, expected)
781 }
782 expectedUTC := timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2015, 2, 24, 21, 19, 39, 123456789, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)
783 if !tm.Inscip-go gomod github.com/golang/go/src go1.15 time/Time#In().(timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.).Equalscip-go gomod github.com/golang/go/src go1.15 time/Time#Equal().(expectedUTC) {
784 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() in UTC returned %v, want %v", tm.Inscip-go gomod github.com/golang/go/src go1.15 time/Time#In().(timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.), expectedUTC)
785 }
786 }
787
788 func TestDecoderSingleDocumentscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestDecoderSingleDocument().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
789 // Test that Decoder.Decode works as expected on
790 // all the unmarshal tests.
791 for i, item := range unmarshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests. {
792 t.Logfscip-go gomod github.com/golang/go/src go1.15 testing/common#Logf().("test %d: %q", i, item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data.)
793 if item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data. == "" {
794 // Behaviour differs when there's no YAML.
795 continue
796 }
797 typ := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value.).Typescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Type().()
798 value := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Newscip-go gomod github.com/golang/go/src go1.15 reflect/New().(typ)
799 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewDecoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewDecoder().(stringsscip-go gomod github.com/golang/go/src go1.15 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.15 strings/NewReader().(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:data.)).Decodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Decoder#Decode().(value.Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().())
800 if _, ok := err.(*yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.TypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/TypeError#); !ok {
801 if err != nil {
802 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned error: %v", err)
803 }
804 }
805 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value.) {
806 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned %#v, want %#v", value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalTests:value.)
807 }
808 }
809 }
810
811 var decoderTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests. = []struct {
812 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:data. string
813 valuesscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:values. []interface{}
814 }{{
815 "",
816 nil,
817 }, {
818 "a: b",
819 []interface{}{
820 map[interface{}]interface{}{"a": "b"},
821 },
822 }, {
823 "---\na: b\n...\n",
824 []interface{}{
825 map[interface{}]interface{}{"a": "b"},
826 },
827 }, {
828 "---\n'hello'\n...\n---\ngoodbye\n...\n",
829 []interface{}{
830 "hello",
831 "goodbye",
832 },
833 }}
834
835 func TestDecoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestDecoder().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
836 for i, item := range decoderTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests. {
837 t.Logfscip-go gomod github.com/golang/go/src go1.15 testing/common#Logf().("test %d: %q", i, item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:data.)
838 var values []interface{}
839 dec := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewDecoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewDecoder().(stringsscip-go gomod github.com/golang/go/src go1.15 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.15 strings/NewReader().(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:data.))
840 for {
841 var value interface{}
842 err := dec.Decodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Decoder#Decode().(&value)
843 if err == ioscip-go gomod github.com/golang/go/src go1.15 io/.EOFscip-go gomod github.com/golang/go/src go1.15 io/EOF. {
844 break
845 }
846 if err != nil {
847 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned error: %v", err)
848 }
849 values = append(values, value)
850 }
851 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(values, item.valuesscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:values.) {
852 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned %#v, want %#v", values, item.valuesscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/decoderTests:values.)
853 }
854 }
855 }
856
857 type errReaderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errReader# struct{}
858
859 func (errReaderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errReader#) Readscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errReader#Read().([]byte) (int, error) {
860 return 0, errorsscip-go gomod github.com/golang/go/src go1.15 errors/.Newscip-go gomod github.com/golang/go/src go1.15 errors/New().("some read error")
861 }
862
863 func TestDecoderReadErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestDecoderReadError().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
864 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewDecoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewDecoder().(errReaderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errReader#{}).Decodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Decoder#Decode().(&struct{}{})
865 if err == nil || !stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Containsscip-go gomod github.com/golang/go/src go1.15 strings/Contains().(err.Error(), `yaml: input error: some read error`) {
866 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned %v, want error containing %q", err, `yaml: input error: some read error`)
867 }
868 }
869
870 func TestUnmarshalNaNscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalNaN().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
871 value := map[string]interface{}{}
872 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("notanum: .NaN"), &value)
873 if err != nil {
874 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
875 }
876 if !mathscip-go gomod github.com/golang/go/src go1.15 math/.IsNaNscip-go gomod github.com/golang/go/src go1.15 math/IsNaN().(value["notanum"].(float64)) {
877 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want NaN", value["notanum"])
878 }
879 }
880
881 var unmarshalErrorTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests. = []struct {
882 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data., errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error. string
883 }{
884 {"v: !!float 'error'", "yaml: cannot decode !!str `error` as a !!float"},
885 {"v: [A,", "yaml: line 1: did not find expected node content"},
886 {"v:\n- [A,", "yaml: line 2: did not find expected node content"},
887 {"a:\n- b: *,", "yaml: line 2: did not find expected alphabetic or numeric character"},
888 {"a: *b\n", "yaml: unknown anchor 'b' referenced"},
889 {"a: &a\n b: *a\n", "yaml: anchor 'a' value contains itself"},
890 {"a: &x null\n<<:\n- *x\nb: &x {}\n", `yaml: map merge requires map or sequence of maps as the value`}, // Issue #529.
891 {"value: -", "yaml: block sequence entries are not allowed in this context"},
892 {"a: !!binary ==", "yaml: !!binary value contains invalid base64 data"},
893 {"{[.]}", `yaml: invalid map key: []interface {}{"."}`},
894 {"{{.}}", `yaml: invalid map key: map[interface {}]interface {}{".":interface {}(nil)}`},
895 {"b: *a\na: &a {c: 1}", `yaml: unknown anchor 'a' referenced`},
896 {"%TAG !%79! tag:yaml.org,2002:\n---\nv: !%79!int '1'", "yaml: did not find expected whitespace"},
897 {"a:\n 1:\nb\n 2:", "could not find expected ':'"},
898 {
899 "a: &a [00,00,00,00,00,00,00,00,00]\n" +
900 "b: &b [*a,*a,*a,*a,*a,*a,*a,*a,*a]\n" +
901 "c: &c [*b,*b,*b,*b,*b,*b,*b,*b,*b]\n" +
902 "d: &d [*c,*c,*c,*c,*c,*c,*c,*c,*c]\n" +
903 "e: &e [*d,*d,*d,*d,*d,*d,*d,*d,*d]\n" +
904 "f: &f [*e,*e,*e,*e,*e,*e,*e,*e,*e]\n" +
905 "g: &g [*f,*f,*f,*f,*f,*f,*f,*f,*f]\n" +
906 "h: &h [*g,*g,*g,*g,*g,*g,*g,*g,*g]\n" +
907 "i: &i [*h,*h,*h,*h,*h,*h,*h,*h,*h]\n",
908 "yaml: document contains excessive aliasing",
909 },
910 }
911
912 func TestUnmarshalErrorsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalErrors().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
913 for i, item := range unmarshalErrorTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests. {
914 t.Logfscip-go gomod github.com/golang/go/src go1.15 testing/common#Logf().("test %d: %q", i, item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data.)
915 var value interface{}
916 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data.), &value)
917 if err == nil {
918 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() expected error, got none. Partial unmarshal: %#v", value)
919 }
920 if !stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Containsscip-go gomod github.com/golang/go/src go1.15 strings/Contains().(err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error.) {
921 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error %q, want containing %q. Partial unmarshal: %#v", err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error., value)
922 }
923
924 if stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Containsscip-go gomod github.com/golang/go/src go1.15 strings/Contains().(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data., ":") {
925 // Repeat test with typed value.
926 var mapValue map[string]interface{}
927 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data.), &mapValue)
928 if err == nil {
929 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() with map[string]interface{} expected error, got none. Partial unmarshal: %#v", mapValue)
930 }
931 if !stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Containsscip-go gomod github.com/golang/go/src go1.15 strings/Contains().(err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error.) {
932 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() with map[string]interface{} returned error %q, want containing %q. Partial unmarshal: %#v", err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error., mapValue)
933 }
934 }
935 }
936 }
937
938 func TestDecoderErrorsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestDecoderErrors().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
939 for _, item := range unmarshalErrorTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests. {
940 var value interface{}
941 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewDecoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewDecoder().(stringsscip-go gomod github.com/golang/go/src go1.15 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.15 strings/NewReader().(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:data.)).Decodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Decoder#Decode().(&value)
942 if err == nil {
943 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() expected error, got none. Partial unmarshal: %#v", value)
944 }
945 if !stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Containsscip-go gomod github.com/golang/go/src go1.15 strings/Contains().(err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error.) {
946 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Decode() returned error %q, want containing %q. Partial unmarshal: %#v", err.Error(), item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalErrorTests:error., value)
947 }
948 }
949 }
950
951 var unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests. = []struct {
952 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:data., tagscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:tag. string
953 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value. interface{}
954 }{
955 {"_: {hi: there}", "!!map", map[interface{}]interface{}{"hi": "there"}},
956 {"_: [1,A]", "!!seq", []interface{}{1, "A"}},
957 {"_: 10", "!!int", 10},
958 {"_: null", "!!null", nil},
959 {`_: BAR!`, "!!str", "BAR!"},
960 {`_: "BAR!"`, "!!str", "BAR!"},
961 {"_: !!foo 'BAR!'", "!!foo", "BAR!"},
962 {`_: ""`, "!!str", ""},
963 }
964
965 var unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult. = map[int]error{}
966
967 type unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType# struct {
968 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value. interface{}
969 }
970
971 func (o *unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#) UnmarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#UnmarshalYAML().(unmarshal func(v interface{}) error) error {
972 if err := unmarshal(&o.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value.); err != nil {
973 return err
974 }
975 if i, ok := o.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value..(int); ok {
976 if result, ok := unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult.[i]; ok {
977 return result
978 }
979 }
980 return nil
981 }
982
983 type unmarshalerPointerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer# struct {
984 Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field. *unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType# "_"
985 }
986
987 type unmarshalerValuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerValue# struct {
988 Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerValue#Field. unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType# "_"
989 }
990
991 func TestUnmarshalerPointerFieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerPointerField().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
992 for _, item := range unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests. {
993 obj := &unmarshalerPointerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#{}
994 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:data.), obj)
995 if err != nil {
996 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
997 }
998 if item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value. == nil {
999 if obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field. != nil {
1000 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want nil", obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field.)
1001 }
1002 } else {
1003 if obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field. == nil {
1004 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned nil, want non-nil. Value: %#v", item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.)
1005 }
1006 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field..valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.) {
1007 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %#v, want %#v", obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerPointer#Field..valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.)
1008 }
1009 }
1010 }
1011 }
1012
1013 func TestUnmarshalerValueFieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerValueField().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1014 for _, item := range unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests. {
1015 obj := &unmarshalerValuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerValue#{}
1016 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:data.), obj)
1017 if err != nil {
1018 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1019 }
1020 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerValue#Field..valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.) {
1021 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %#v, want %#v", obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerValue#Field..valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.)
1022 }
1023 }
1024 }
1025
1026 func TestUnmarshalerWholeDocumentscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerWholeDocument().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1027 obj := &unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#{}
1028 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests.[0].datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:data.), obj)
1029 if err != nil {
1030 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1031 }
1032 value, ok := obj.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value..(map[interface{}]interface{})
1033 if !ok {
1034 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("obj.value is not a map[interface{}]interface{}. Value: %#v", obj.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value.)
1035 }
1036 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(value["_"], unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests.[0].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.) {
1037 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %#v but expected %#v", value["_"], unmarshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests.[0].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerTests:value.)
1038 }
1039 }
1040
1041 func TestUnmarshalerTypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerTypeError().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1042 unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult.[2] = &yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.TypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/TypeError#{[]string{"foo"}}
1043 unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult.[4] = &yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.TypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/TypeError#{[]string{"bar"}}
1044 defer func() {
1045 delete(unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult., 2)
1046 delete(unmarshalerResultscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerResult., 4)
1047 }()
1048
1049 type T struct {
1050 Before int
1051 After int
1052 M map[string]*unmarshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#
1053 }
1054 var v T
1055 data := `{before: A, m: {abc: 1, def: 2, ghi: 3, jkl: 4}, after: B}`
1056 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(data), &v)
1057 expectedError := "" +
1058 "yaml: unmarshal errors:\n" +
1059 " line 1: cannot unmarshal !!str `A` into int\n" +
1060 " foo\n" +
1061 " bar\n" +
1062 " line 1: cannot unmarshal !!str `B` into int"
1063 if err == nil {
1064 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() expected error, got none.")
1065 }
1066 if err.Error() != expectedError {
1067 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error %q, want %q", err, expectedError)
1068 }
1069 if v.M["abc"] == nil {
1070 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"abc\"] is nil, want non-nil")
1071 }
1072 if v.M["def"] != nil {
1073 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"def\"] is not nil, want nil")
1074 }
1075 if v.M["ghi"] == nil {
1076 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"ghi\"] is nil, want non-nil")
1077 }
1078 if v.M["jkl"] != nil {
1079 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"jkl\"] is not nil, want nil")
1080 }
1081
1082 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(v.M["abc"].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., 1) {
1083 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"abc\"].value is %v, want %v", v.M["abc"].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., 1)
1084 }
1085 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(v.M["ghi"].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., 3) {
1086 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.M[\"ghi\"].value is %v, want %v", v.M["ghi"].valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalerType#value., 3)
1087 }
1088 }
1089
1090 type proxyTypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/proxyTypeError# struct{}
1091
1092 func (v *proxyTypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/proxyTypeError#) UnmarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/proxyTypeError#UnmarshalYAML().(unmarshal func(interface{}) error) error {
1093 var s string
1094 var a int32
1095 var b int64
1096 if err := unmarshal(&s); err != nil {
1097 panic(err)
1098 }
1099 if s == "a" {
1100 if err := unmarshal(&b); err == nil {
1101 panic("should have failed")
1102 }
1103 return unmarshal(&a)
1104 }
1105 if err := unmarshal(&a); err == nil {
1106 panic("should have failed")
1107 }
1108 return unmarshal(&b)
1109 }
1110
1111 func TestUnmarshalerTypeErrorProxyingscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerTypeErrorProxying().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1112 type T struct {
1113 Before int
1114 After int
1115 M map[string]*proxyTypeErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/proxyTypeError#
1116 }
1117 var v T
1118 data := `{before: A, m: {abc: a, def: b}, after: B}`
1119 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(data), &v)
1120 expectedError := "" +
1121 "yaml: unmarshal errors:\n" +
1122 " line 1: cannot unmarshal !!str `A` into int\n" +
1123 " line 1: cannot unmarshal !!str `a` into int32\n" +
1124 " line 1: cannot unmarshal !!str `b` into int64\n" +
1125 " line 1: cannot unmarshal !!str `B` into int"
1126 if err == nil {
1127 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() expected error, got none.")
1128 }
1129 if err.Error() != expectedError {
1130 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error %q, want %q", err, expectedError)
1131 }
1132 }
1133
1134 type failingUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingUnmarshaler# struct{}
1135
1136 var failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr. = errorsscip-go gomod github.com/golang/go/src go1.15 errors/.Newscip-go gomod github.com/golang/go/src go1.15 errors/New().("failingErr")
1137
1138 func (ft *failingUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingUnmarshaler#) UnmarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingUnmarshaler#UnmarshalYAML().(unmarshal func(interface{}) error) error {
1139 return failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr.
1140 }
1141
1142 func TestUnmarshalerErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerError().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1143 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("a: b"), &failingUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingUnmarshaler#{})
1144 if err != failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr. {
1145 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", err, failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr.)
1146 }
1147 }
1148
1149 type sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler# []int
1150
1151 func (su *sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#) UnmarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#UnmarshalYAML().(unmarshal func(interface{}) error) error {
1152 var slice []int
1153 err := unmarshal(&slice)
1154 if err == nil {
1155 *su = slice
1156 return nil
1157 }
1158
1159 var intVal int
1160 err = unmarshal(&intVal)
1161 if err == nil {
1162 *su = []int{intVal}
1163 return nil
1164 }
1165
1166 return err
1167 }
1168
1169 func TestUnmarshalerRetryscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalerRetry().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1170 var su sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#
1171 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("[1, 2, 3]"), &su)
1172 if err != nil {
1173 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1174 }
1175 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(su, sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#([]int{1, 2, 3})) {
1176 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", su, sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#([]int{1, 2, 3}))
1177 }
1178
1179 err = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("1"), &su)
1180 if err != nil {
1181 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1182 }
1183 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(su, sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#([]int{1})) {
1184 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", su, sliceUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/sliceUnmarshaler#([]int{1}))
1185 }
1186 }
1187
1188 // From http://yaml.org/type/merge.html
1189 var mergeTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/mergeTests. = `
1190 anchors:
1191 list:
1192 - &CENTER { "x": 1, "y": 2 }
1193 - &LEFT { "x": 0, "y": 2 }
1194 - &BIG { "r": 10 }
1195 - &SMALL { "r": 1 }
1196
1197 # All the following maps are equal:
1198
1199 plain:
1200 # Explicit keys
1201 "x": 1
1202 "y": 2
1203 "r": 10
1204 label: center/big
1205
1206 mergeOne:
1207 # Merge one map
1208 << : *CENTER
1209 "r": 10
1210 label: center/big
1211
1212 mergeMultiple:
1213 # Merge multiple maps
1214 << : [ *CENTER, *BIG ]
1215 label: center/big
1216
1217 override:
1218 # Override
1219 << : [ *BIG, *LEFT, *SMALL ]
1220 "x": 1
1221 label: center/big
1222
1223 shortTag:
1224 # Explicit short merge tag
1225 !!merge "<<" : [ *CENTER, *BIG ]
1226 label: center/big
1227
1228 longTag:
1229 # Explicit merge long tag
1230 !<tag:yaml.org,2002:merge> "<<" : [ *CENTER, *BIG ]
1231 label: center/big
1232
1233 inlineMap:
1234 # Inlined map
1235 << : {"x": 1, "y": 2, "r": 10}
1236 label: center/big
1237
1238 inlineSequenceMap:
1239 # Inlined map in sequence
1240 << : [ *CENTER, {"r": 10} ]
1241 label: center/big
1242 `
1243
1244 func TestMergescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMerge().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1245 var want = map[interface{}]interface{}{
1246 "x": 1,
1247 "y": 2,
1248 "r": 10,
1249 "label": "center/big",
1250 }
1251
1252 var m map[interface{}]interface{}
1253 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(mergeTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/mergeTests.), &m)
1254 if err != nil {
1255 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1256 }
1257 for name, test := range m {
1258 if name == "anchors" {
1259 continue
1260 }
1261 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(test, want) {
1262 t.Errorfscip-go gomod github.com/golang/go/src go1.15 testing/common#Errorf().("test %q failed: got %#v, want %#v", name, test, want)
1263 }
1264 }
1265 }
1266
1267 func TestMergeStructscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMergeStruct().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1268 type Data struct {
1269 X, Y, R int
1270 Label string
1271 }
1272 want := Data{1, 2, 10, "center/big"}
1273
1274 var m map[string]Data
1275 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(mergeTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/mergeTests.), &m)
1276 if err != nil {
1277 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1278 }
1279 for name, test := range m {
1280 if name == "anchors" {
1281 continue
1282 }
1283 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(test, want) {
1284 t.Errorfscip-go gomod github.com/golang/go/src go1.15 testing/common#Errorf().("test %q failed: got %#v, want %#v", name, test, want)
1285 }
1286 }
1287 }
1288
1289 var unmarshalNullTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests. = []func() interface{}{
1290 func() interface{} { var vscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:v. interface{}; vscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:v. = "v"; return &vscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:v. },
1291 func() interface{} { var sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:s. = "s"; return &sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:s. },
1292 func() interface{} { var sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:s. = "s"; sptr := &sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:s.; return &sptr },
1293 func() interface{} { var iscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:i. = 1; return &iscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:i. },
1294 func() interface{} { var iscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:i. = 1; iptr := &iscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests:i.; return &iptr },
1295 func() interface{} { m := map[string]int{"s": 1}; return &m },
1296 func() interface{} { m := map[string]int{"s": 1}; return m },
1297 }
1298
1299 func TestUnmarshalNullscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalNull().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1300 for _, test := range unmarshalNullTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalNullTests. {
1301 item := test()
1302 zero := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Zeroscip-go gomod github.com/golang/go/src go1.15 reflect/Zero().(reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.15 reflect/TypeOf().(item).Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Type#Elem().()).Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().()
1303 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("null"), item)
1304 if err != nil {
1305 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1306 }
1307 if reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.15 reflect/TypeOf().(item).Kindscip-go gomod github.com/golang/go/src go1.15 reflect/Type#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Mapscip-go gomod github.com/golang/go/src go1.15 reflect/Map. {
1308 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item).Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.MakeMapscip-go gomod github.com/golang/go/src go1.15 reflect/MakeMap().(reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.15 reflect/TypeOf().(item)).Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().()) {
1309 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want empty map", reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item).Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().())
1310 }
1311 } else {
1312 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item).Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), zero) {
1313 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item).Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), zero)
1314 }
1315 }
1316 }
1317 }
1318
1319 func TestUnmarshalSliceOnPresetscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalSliceOnPreset().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1320 // Issue #48.
1321 v := struct{ A []int }{[]int{1}}
1322 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte("a: [2]"), &v)
1323 if err != nil {
1324 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1325 }
1326 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(v.A, []int{2}) {
1327 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("v.A is %v, want %v", v.A, []int{2})
1328 }
1329 }
1330
1331 var unmarshalStrictTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests. = []struct {
1332 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data. string
1333 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value. interface{}
1334 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error. string
1335 }{{
1336 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "a: 1\nc: 2\n",
1337 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A., Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:B. int }{Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A.: 1},
1338 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 2: field c not found in type struct { A int; B int }",
1339 }, {
1340 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "a: 1\nb: 2\na: 3\n",
1341 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A., Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:B. int }{Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A.: 3, Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:B.: 2},
1342 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 3: field a already set in type struct { A int; B int }",
1343 }, {
1344 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "c: 3\na: 1\nb: 2\nc: 4\n",
1345 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: struct {
1346 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A. int
1347 inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:inlineB. `yaml:",inline"`
1348 }{
1349 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A.: 1,
1350 inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:inlineB.: inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#{
1351 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#B.: 2,
1352 inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#inlineC.: inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#{
1353 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#C.: 4,
1354 },
1355 },
1356 },
1357 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 4: field c already set in type struct { A int; yaml_test.inlineB \"yaml:\\\",inline\\\"\" }",
1358 }, {
1359 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "c: 0\na: 1\nb: 2\nc: 1\n",
1360 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: struct {
1361 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A. int
1362 inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:inlineB. `yaml:",inline"`
1363 }{
1364 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A.: 1,
1365 inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:inlineB.: inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#{
1366 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#B.: 2,
1367 inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB#inlineC.: inlineCscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#{
1368 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineC#C.: 1,
1369 },
1370 },
1371 },
1372 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 4: field c already set in type struct { A int; yaml_test.inlineB \"yaml:\\\",inline\\\"\" }",
1373 }, {
1374 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "c: 1\na: 1\nb: 2\nc: 3\n",
1375 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: struct {
1376 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A. int
1377 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:M. map[string]interface{} `yaml:",inline"`
1378 }{
1379 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:A.: 1,
1380 Mscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:M.: map[string]interface{}{
1381 "b": 2,
1382 "c": 3,
1383 },
1384 },
1385 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 4: key \"c\" already set in map",
1386 }, {
1387 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.: "a: 1\n9: 2\nnull: 3\n9: 4",
1388 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.: map[interface{}]interface{}{
1389 "a": 1,
1390 nil: 3,
1391 9: 4,
1392 },
1393 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.: "yaml: unmarshal errors:\n line 4: key 9 already set in map",
1394 }}
1395
1396 func TestUnmarshalStrictscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestUnmarshalStrict().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1397 for i, item := range unmarshalStrictTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests. {
1398 t.Logfscip-go gomod github.com/golang/go/src go1.15 testing/common#Logf().("test %d: %q", i, item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.)
1399 // First test that normal Unmarshal unmarshals to the expected value.
1400 typ := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.).Typescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Type().()
1401 value := reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Newscip-go gomod github.com/golang/go/src go1.15 reflect/New().(typ)
1402 err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.), value.Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().())
1403 if err != nil {
1404 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned error: %v", err)
1405 }
1406 if !reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.15 reflect/DeepEqual().(value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.) {
1407 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Unmarshal() returned %v, want %v", value.Elemscip-go gomod github.com/golang/go/src go1.15 reflect/Value#Elem().().Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().(), item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.)
1408 }
1409
1410 // Then test that UnmarshalStrict fails on the same thing.
1411 typ = reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.15 reflect/ValueOf().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:value.).Typescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Type().()
1412 value = reflectscip-go gomod github.com/golang/go/src go1.15 reflect/.Newscip-go gomod github.com/golang/go/src go1.15 reflect/New().(typ)
1413 err = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.UnmarshalStrictscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/UnmarshalStrict().([]byte(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:data.), value.Interfacescip-go gomod github.com/golang/go/src go1.15 reflect/Value#Interface().())
1414 if err == nil {
1415 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("UnmarshalStrict() returned no error, want %q", item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.)
1416 }
1417 if err.Error() != item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error. {
1418 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("UnmarshalStrict() returned error %q, want %q", err, item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/unmarshalStrictTests:error.)
1419 }
1420 }
1421 }
1422
1423 type textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler# struct {
1424 Sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#S. string
1425 }
1426
1427 func (t *textUnmarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#) UnmarshalTextscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#UnmarshalText().(s []byte) error {
1428 t.Sscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/textUnmarshaler#S. = string(s)
1429 return nil
1430 }
1431
1432 func TestFuzzCrashersscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestFuzzCrashers().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
1433 cases := []string{
1434 // runtime error: index out of range
1435 "\"\\0\\\r\n",
1436
1437 // should not happen
1438 " 0: [\n] 0",
1439 "? ? \"\n\" 0",
1440 " - {\n000}0",
1441 "0:\n 0: [0\n] 0",
1442 " - \"\n000\"0",
1443 " - \"\n000\"\"",
1444 "0:\n - {\n000}0",
1445 "0:\n - \"\n000\"0",
1446 "0:\n - \"\n000\"\"",
1447
1448 // runtime error: index out of range
1449 " \ufeff\n",
1450 "? \ufeff\n",
1451 "? \ufeff:\n",
1452 "0: \ufeff\n",
1453 "? \ufeff: \ufeff\n",
1454 }
1455 for _, data := range cases {
1456 var v interface{}
1457 _ = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Unmarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Unmarshal().([]byte(data), &v)
1458 }
1459 }
1460
1461 //var data []byte
1462 //func init() {
1463 // var err error
1464 // data, err = ioutil.ReadFile("/tmp/file.yaml")
1465 // if err != nil {
1466 // panic(err)
1467 // }
1468 //}
1469 //
1470 //func (s *S) BenchmarkUnmarshal(c *C) {
1471 // var err error
1472 // for i := 0; i < c.N; i++ {
1473 // var v map[string]interface{}
1474 // err = yaml.Unmarshal(data, &v)
1475 // }
1476 // if err != nil {
1477 // panic(err)
1478 // }
1479 //}
1480 //
1481 //func (s *S) BenchmarkMarshal(c *C) {
1482 // var v map[string]interface{}
1483 // yaml.Unmarshal(data, &v)
1484 // c.ResetTimer()
1485 // for i := 0; i < c.N; i++ {
1486 // yaml.Marshal(&v)
1487 // }
1488 //}