Debian Codegraph @

encode_test.go

raw symbols SCIP
1 package yaml_testscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.15 bytes/"
5 "fmtscip-go gomod github.com/golang/go/src go1.15 fmt/"
6 "mathscip-go gomod github.com/golang/go/src go1.15 math/"
7 "netscip-go gomod github.com/golang/go/src go1.15 net/"
8 "osscip-go gomod github.com/golang/go/src go1.15 os/"
9 "strconvscip-go gomod github.com/golang/go/src go1.15 strconv/"
10 "stringsscip-go gomod github.com/golang/go/src go1.15 strings/"
11 "testingscip-go gomod github.com/golang/go/src go1.15 testing/"
12 "timescip-go gomod github.com/golang/go/src go1.15 time/"
13
14 "go.yaml.in/yaml/v2scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/"
15 )
16
17 type jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT# string
18
19 func (j jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#) Int64scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#Int64().() (int64, error) {
20 val, err := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(string(j))
21 if err != nil {
22 return 0, err
23 }
24 return int64(val), nil
25 }
26
27 func (j jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#) Float64scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#Float64().() (float64, error) {
28 return strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.15 strconv/ParseFloat().(string(j), 64)
29 }
30
31 func (j jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#) Stringscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#String().() string {
32 return string(j)
33 }
34
35 var marshalIntTestscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalIntTest. = 123
36
37 var marshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests. = []struct {
38 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:value. interface{}
39 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:data. string
40 }{
41 {
42 nil,
43 "null\n",
44 }, {
45 (*marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#)(nil),
46 "null\n",
47 }, {
48 &struct{}{},
49 "{}\n",
50 }, {
51 map[string]string{"v": "hi"},
52 "v: hi\n",
53 }, {
54 map[string]interface{}{"v": "hi"},
55 "v: hi\n",
56 }, {
57 map[string]string{"v": "true"},
58 "v: \"true\"\n",
59 }, {
60 map[string]string{"v": "false"},
61 "v: \"false\"\n",
62 }, {
63 map[string]interface{}{"v": true},
64 "v: true\n",
65 }, {
66 map[string]interface{}{"v": false},
67 "v: false\n",
68 }, {
69 map[string]interface{}{"v": 10},
70 "v: 10\n",
71 }, {
72 map[string]interface{}{"v": -10},
73 "v: -10\n",
74 }, {
75 map[string]uint{"v": 42},
76 "v: 42\n",
77 }, {
78 map[string]interface{}{"v": int64(4294967296)},
79 "v: 4294967296\n",
80 }, {
81 map[string]int64{"v": int64(4294967296)},
82 "v: 4294967296\n",
83 }, {
84 map[string]uint64{"v": 4294967296},
85 "v: 4294967296\n",
86 }, {
87 map[string]interface{}{"v": "10"},
88 "v: \"10\"\n",
89 }, {
90 map[string]interface{}{"v": 0.1},
91 "v: 0.1\n",
92 }, {
93 map[string]interface{}{"v": float64(0.1)},
94 "v: 0.1\n",
95 }, {
96 map[string]interface{}{"v": float32(0.99)},
97 "v: 0.99\n",
98 }, {
99 map[string]interface{}{"v": -0.1},
100 "v: -0.1\n",
101 }, {
102 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)},
103 "v: .inf\n",
104 }, {
105 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)},
106 "v: -.inf\n",
107 }, {
108 map[string]interface{}{"v": mathscip-go gomod github.com/golang/go/src go1.15 math/.NaNscip-go gomod github.com/golang/go/src go1.15 math/NaN().()},
109 "v: .nan\n",
110 }, {
111 map[string]interface{}{"v": nil},
112 "v: null\n",
113 }, {
114 map[string]interface{}{"v": ""},
115 "v: \"\"\n",
116 }, {
117 map[string][]string{"v": []string{"A", "B"}},
118 "v:\n- A\n- B\n",
119 }, {
120 map[string][]string{"v": []string{"A", "B\nC"}},
121 "v:\n- A\n- |-\n B\n C\n",
122 }, {
123 map[string][]interface{}{"v": []interface{}{"A", 1, map[string][]int{"B": []int{2, 3}}}},
124 "v:\n- A\n- 1\n- B:\n - 2\n - 3\n",
125 }, {
126 map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"}},
127 "a:\n b: c\n",
128 }, {
129 map[string]interface{}{"a": "-"},
130 "a: '-'\n",
131 },
132
133 // Simple values.
134 {
135 &marshalIntTestscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalIntTest.,
136 "123\n",
137 },
138
139 // Structures
140 {
141 &struct{ Helloscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:Hello. string }{"world"},
142 "hello: world\n",
143 }, {
144 &struct {
145 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. struct {
146 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_6f306943eb750927#B. string
147 }
148 }{struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. string }{"c"}},
149 "a:\n b: c\n",
150 }, {
151 &struct {
152 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. *struct {
153 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_6f306943eb750927#B. string
154 }
155 }{&struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. string }{"c"}},
156 "a:\n b: c\n",
157 }, {
158 &struct {
159 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. *struct {
160 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_6f306943eb750927#B. string
161 }
162 }{},
163 "a: null\n",
164 }, {
165 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int }{1},
166 "a: 1\n",
167 }, {
168 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. []int }{[]int{1, 2}},
169 "a:\n- 1\n- 2\n",
170 }, {
171 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. [2]int }{[2]int{1, 2}},
172 "a:\n- 1\n- 2\n",
173 }, {
174 &struct {
175 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. int "a"
176 }{1},
177 "a: 1\n",
178 }, {
179 &struct{ Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. bool }{true},
180 "a: true\n",
181 },
182
183 // Conditional flag
184 {
185 &struct {
186 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int "a,omitempty"
187 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. int "b,omitempty"
188 }{1, 0},
189 "a: 1\n",
190 }, {
191 &struct {
192 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int "a,omitempty"
193 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. int "b,omitempty"
194 }{0, 0},
195 "{}\n",
196 }, {
197 &struct {
198 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. *struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#y. int } "a,omitempty,flow"
199 }{&struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:y. int }{1, 2}},
200 "a: {x: 1}\n",
201 }, {
202 &struct {
203 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. *struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#y. int } "a,omitempty,flow"
204 }{nil},
205 "{}\n",
206 }, {
207 &struct {
208 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. *struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#y. int } "a,omitempty,flow"
209 }{&struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:y. int }{}},
210 "a: {x: 0}\n",
211 }, {
212 &struct {
213 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#y. int } "a,omitempty,flow"
214 }{struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:y. int }{1, 2}},
215 "a: {x: 1}\n",
216 }, {
217 &struct {
218 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_0b19be1edb0c1280#y. int } "a,omitempty,flow"
219 }{struct{ Xscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:X., yscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:y. int }{0, 1}},
220 "{}\n",
221 }, {
222 &struct {
223 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. float64 "a,omitempty"
224 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. float64 "b,omitempty"
225 }{1, 0},
226 "a: 1\n",
227 },
228 {
229 &struct {
230 T1scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T1. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# "t1,omitempty"
231 T2scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T2. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# "t2,omitempty"
232 T3scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T3. *timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# "t3,omitempty"
233 T4scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T4. *timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# "t4,omitempty"
234 }{
235 T2scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T2.: timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2018, 1, 9, 10, 40, 47, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.),
236 T4scip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:T4.: newTimescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/newTime().(timescip-go gomod github.com/golang/go/src go1.15 time/.Datescip-go gomod github.com/golang/go/src go1.15 time/Date().(2098, 1, 9, 10, 40, 47, 0, timescip-go gomod github.com/golang/go/src go1.15 time/.UTCscip-go gomod github.com/golang/go/src go1.15 time/UTC.)),
237 },
238 "t2: 2018-01-09T10:40:47Z\nt4: 2098-01-09T10:40:47Z\n",
239 },
240 // Nil interface that implements Marshaler.
241 {
242 map[string]yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshaler#{
243 "a": nil,
244 },
245 "a: null\n",
246 },
247
248 // Flow flag
249 {
250 &struct {
251 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. []int "a,flow"
252 }{[]int{1, 2}},
253 "a: [1, 2]\n",
254 }, {
255 &struct {
256 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. map[string]string "a,flow"
257 }{map[string]string{"b": "c", "d": "e"}},
258 "a: {b: c, d: e}\n",
259 }, {
260 &struct {
261 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. struct {
262 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_a44a0946f6fbbdac#B., Dscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:$anon_a44a0946f6fbbdac#D. string
263 } "a,flow"
264 }{struct{ Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B., Dscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:D. string }{"c", "e"}},
265 "a: {b: c, d: e}\n",
266 },
267
268 // Unexported field
269 {
270 &struct {
271 uscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:u. int
272 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int
273 }{0, 1},
274 "a: 1\n",
275 },
276
277 // Ignored field
278 {
279 &struct {
280 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int
281 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:B. int "-"
282 }{1, 2},
283 "a: 1\n",
284 },
285
286 // Struct inlining
287 {
288 &struct {
289 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int
290 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:C. inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/inlineB# `yaml:",inline"`
291 }{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}}},
292 "a: 1\nb: 2\nc: 3\n",
293 },
294
295 // Map inlining
296 {
297 &struct {
298 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:A. int
299 Cscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:C. map[string]int `yaml:",inline"`
300 }{1, map[string]int{"b": 2, "c": 3}},
301 "a: 1\nb: 2\nc: 3\n",
302 },
303
304 // Duration
305 {
306 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.},
307 "a: 3s\n",
308 },
309
310 // Issue #24: bug in map merging logic.
311 {
312 map[string]string{"a": "<foo>"},
313 "a: <foo>\n",
314 },
315
316 // Issue #34: marshal unsupported base 60 floats quoted for compatibility
317 // with old YAML 1.1 parsers.
318 {
319 map[string]string{"a": "1:1"},
320 "a: \"1:1\"\n",
321 },
322
323 // Binary data.
324 {
325 map[string]string{"a": "\x00"},
326 "a: \"\\0\"\n",
327 }, {
328 map[string]string{"a": "\x80\x81\x82"},
329 "a: !!binary gIGC\n",
330 }, {
331 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)},
332 "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",
333 },
334
335 // Ordered maps.
336 {
337 &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}}}},
338 "b: 2\na: 1\nd: 4\nc: 3\nsub:\n e: 5\n",
339 },
340
341 // Encode unicode as utf-8 rather than in escaped form.
342 {
343 map[string]string{"a": "你好"},
344 "a: 你好\n",
345 },
346
347 // Support encoding.TextMarshaler.
348 {
349 map[string]netscip-go gomod github.com/golang/go/src go1.15 net/.IPscip-go gomod github.com/golang/go/src go1.15 net/IP#{"a": netscip-go gomod github.com/golang/go/src go1.15 net/.IPv4scip-go gomod github.com/golang/go/src go1.15 net/IPv4().(1, 2, 3, 4)},
350 "a: 1.2.3.4\n",
351 },
352 // time.Time gets a timestamp tag.
353 {
354 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.)},
355 "a: 2015-02-24T18:19:39Z\n",
356 },
357 {
358 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": newTimescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/newTime().(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.))},
359 "a: 2015-02-24T18:19:39Z\n",
360 },
361 {
362 // This is confirmed to be properly decoded in Python (libyaml) without a timestamp tag.
363 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, 123456789, timescip-go gomod github.com/golang/go/src go1.15 time/.FixedZonescip-go gomod github.com/golang/go/src go1.15 time/FixedZone().("FOO", -3*60*60))},
364 "a: 2015-02-24T18:19:39.123456789-03:00\n",
365 },
366 // Ensure timestamp-like strings are quoted.
367 {
368 map[string]string{"a": "2015-02-24T18:19:39Z"},
369 "a: \"2015-02-24T18:19:39Z\"\n",
370 },
371
372 // Ensure strings containing ": " are quoted (reported as PR #43, but not reproducible).
373 {
374 map[string]string{"a": "b: c"},
375 "a: 'b: c'\n",
376 },
377
378 // Containing hash mark ('#') in string should be quoted
379 {
380 map[string]string{"a": "Hello #comment"},
381 "a: 'Hello #comment'\n",
382 },
383 {
384 map[string]string{"a": "你好 #comment"},
385 "a: '你好 #comment'\n",
386 },
387 {
388 map[string]interface{}{"a": jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#("5")},
389 "a: 5\n",
390 },
391 {
392 map[string]interface{}{"a": jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#("100.5")},
393 "a: 100.5\n",
394 },
395 {
396 map[string]interface{}{"a": jsonNumberTscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/jsonNumberT#("bogus")},
397 "a: bogus\n",
398 },
399 }
400
401 func TestLineWrappingscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestLineWrapping().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
402 var v = map[string]string{
403 "a": "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ",
404 }
405 data, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(v)
406 if err != nil {
407 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
408 }
409 expected := "a: 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz\n" +
410 " ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 '\n"
411 if string(data) != expected {
412 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), expected)
413 }
414
415 // The API does not allow this process to be reversed as it's intended
416 // for migration only. v3 drops this method and instead offers more
417 // control on a per encoding basis.
418 yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.FutureLineWrapscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/FutureLineWrap().()
419
420 data, err = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(v)
421 if err != nil {
422 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
423 }
424 expected = "a: 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 '\n"
425 if string(data) != expected {
426 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), expected)
427 }
428 }
429
430 func TestMarshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshal().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
431 defer osscip-go gomod github.com/golang/go/src go1.15 os/.Setenvscip-go gomod github.com/golang/go/src go1.15 os/Setenv().("TZ", osscip-go gomod github.com/golang/go/src go1.15 os/.Getenvscip-go gomod github.com/golang/go/src go1.15 os/Getenv().("TZ"))
432 osscip-go gomod github.com/golang/go/src go1.15 os/.Setenvscip-go gomod github.com/golang/go/src go1.15 os/Setenv().("TZ", "UTC")
433 for i, item := range marshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests. {
434 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`/marshalTests:data.)
435 data, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:value.)
436 if err != nil {
437 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
438 }
439 if string(data) != item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:data. {
440 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:data.)
441 }
442 }
443 }
444
445 func TestEncoderSingleDocumentscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestEncoderSingleDocument().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
446 for i, item := range marshalTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests. {
447 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`/marshalTests:data.)
448 var buf bytesscip-go gomod github.com/golang/go/src go1.15 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#
449 enc := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewEncoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewEncoder().(&buf)
450 err := enc.Encodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Encode().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:value.)
451 if err != nil {
452 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned error: %v", err)
453 }
454 err = enc.Closescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Close().()
455 if err != nil {
456 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Close() returned error: %v", err)
457 }
458 if buf.Stringscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#String().() != item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:data. {
459 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned %q, want %q", buf.Stringscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#String().(), item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalTests:data.)
460 }
461 }
462 }
463
464 func TestEncoderMultipleDocumentsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestEncoderMultipleDocuments().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
465 var buf bytesscip-go gomod github.com/golang/go/src go1.15 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#
466 enc := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewEncoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewEncoder().(&buf)
467 err := enc.Encodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Encode().(map[string]string{"a": "b"})
468 if err != nil {
469 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned error: %v", err)
470 }
471 err = enc.Encodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Encode().(map[string]string{"c": "d"})
472 if err != nil {
473 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned error: %v", err)
474 }
475 err = enc.Closescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Close().()
476 if err != nil {
477 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Close() returned error: %v", err)
478 }
479 if buf.Stringscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#String().() != "a: b\n---\nc: d\n" {
480 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned %q, want %q", buf.Stringscip-go gomod github.com/golang/go/src go1.15 bytes/Buffer#String().(), "a: b\n---\nc: d\n")
481 }
482 }
483
484 func TestEncoderWriteErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestEncoderWriteError().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
485 enc := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.NewEncoderscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/NewEncoder().(errorWriterscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errorWriter#{})
486 err := enc.Encodescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Encoder#Encode().(map[string]string{"a": "b"})
487 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: write error: some write error`) {
488 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Encode() returned %v, want error containing %q", err, `yaml: write error: some write error`)
489 }
490 }
491
492 type errorWriterscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errorWriter# struct{}
493
494 func (errorWriterscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errorWriter#) Writescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/errorWriter#Write().([]byte) (int, error) {
495 return 0, fmtscip-go gomod github.com/golang/go/src go1.15 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.15 fmt/Errorf().("some write error")
496 }
497
498 var marshalErrorTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests. = []struct {
499 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:value. interface{}
500 errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:error. string
501 panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic. string
502 }{{
503 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:value.: &struct {
504 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:B. int
505 inlineBscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:inlineB. ",inline"
506 }{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}}},
507 panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic.: `Duplicated key 'b' in struct struct { B int; yaml_test.inlineB ",inline" }`,
508 }, {
509 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:value.: &struct {
510 Ascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:A. int
511 Bscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:B. map[string]int ",inline"
512 }{1, map[string]int{"a": 2}},
513 panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic.: `Can't have key "a" in inlined map; conflicts with struct field`,
514 }}
515
516 func TestMarshalErrorsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshalErrors().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
517 for _, item := range marshalErrorTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests. {
518 if item.panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic. != "" {
519 func() {
520 defer func() {
521 r := recover()
522 if r == nil {
523 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("expected panic %q", item.panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic.)
524 }
525 panicText := fmtscip-go gomod github.com/golang/go/src go1.15 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.15 fmt/Sprintf().("%v", r)
526 if panicText != item.panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic. {
527 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("panic value %q does not match %q", panicText, item.panicscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:panic.)
528 }
529 }()
530 yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:value.)
531 }()
532 } else {
533 _, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:value.)
534 if err == nil || err.Error() != item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:error. {
535 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %v, want error %q", err, item.errorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalErrorTests:error.)
536 }
537 }
538 }
539 }
540
541 func TestMarshalTypeCachescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshalTypeCache().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
542 var data []byte
543 var err error
544 func() {
545 type T struct{ A int }
546 data, err = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(&T{})
547 if err != nil {
548 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
549 }
550 }()
551 func() {
552 type T struct{ B int }
553 data, err = yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(&T{})
554 if err != nil {
555 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
556 }
557 }()
558 if string(data) != "b: 0\n" {
559 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), "b: 0\n")
560 }
561 }
562
563 var marshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests. = []struct {
564 datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests:data. string
565 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests:value. interface{}
566 }{
567 {"_:\n hi: there\n", map[interface{}]interface{}{"hi": "there"}},
568 {"_:\n- 1\n- A\n", []interface{}{1, "A"}},
569 {"_: 10\n", 10},
570 {"_: null\n", nil},
571 {"_: BAR!\n", "BAR!"},
572 }
573
574 type marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType# struct {
575 valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#value. interface{}
576 }
577
578 func (o marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#) MarshalTextscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#MarshalText().() ([]byte, error) {
579 panic("MarshalText called on type with MarshalYAML")
580 }
581
582 func (o marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#) MarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#MarshalYAML().() (interface{}, error) {
583 return o.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#value., nil
584 }
585
586 type marshalerValuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerValue# struct {
587 Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerValue#Field. marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType# "_"
588 }
589
590 func TestMarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshaler().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
591 for _, item := range marshalerTestsscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests. {
592 obj := &marshalerValuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerValue#{}
593 obj.Fieldscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerValue#Field..valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#value. = item.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests:value.
594 data, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(obj)
595 if err != nil {
596 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
597 }
598 if string(data) != string(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests:data.) {
599 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), string(item.datascip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerTests:data.))
600 }
601 }
602 }
603
604 func TestMarshalerWholeDocumentscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshalerWholeDocument().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
605 obj := &marshalerTypescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#{}
606 obj.valuescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/marshalerType#value. = map[string]string{"hello": "world!"}
607 data, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(obj)
608 if err != nil {
609 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
610 }
611 if string(data) != "hello: world!\n" {
612 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %q, want %q", string(data), "hello: world!\n")
613 }
614 }
615
616 type failingMarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingMarshaler# struct{}
617
618 func (ft *failingMarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingMarshaler#) MarshalYAMLscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingMarshaler#MarshalYAML().() (interface{}, error) {
619 return nil, failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr.
620 }
621
622 func TestMarshalerErrorscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestMarshalerError().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
623 _, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(&failingMarshalerscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingMarshaler#{})
624 if err != failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr. {
625 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned %v, want %v", err, failingErrscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/failingErr.)
626 }
627 }
628
629 func TestSortedOutputscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/TestSortedOutput().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) {
630 order := []interface{}{
631 false,
632 true,
633 1,
634 uint(1),
635 1.0,
636 1.1,
637 1.2,
638 2,
639 uint(2),
640 2.0,
641 2.1,
642 "",
643 ".1",
644 ".2",
645 ".a",
646 "1",
647 "2",
648 "a!10",
649 "a/0001",
650 "a/002",
651 "a/3",
652 "a/10",
653 "a/11",
654 "a/0012",
655 "a/100",
656 "a~10",
657 "ab/1",
658 "b/1",
659 "b/01",
660 "b/2",
661 "b/02",
662 "b/3",
663 "b/03",
664 "b1",
665 "b01",
666 "b3",
667 "c2.10",
668 "c10.2",
669 "d1",
670 "d7",
671 "d7abc",
672 "d12",
673 "d12a",
674 }
675 m := make(map[interface{}]int)
676 for _, k := range order {
677 m[k] = 1
678 }
679 data, err := yamlscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/.Marshalscip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2`/Marshal().(m)
680 if err != nil {
681 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("Marshal() returned error: %v", err)
682 }
683 out := "\n" + string(data)
684 last := 0
685 for i, k := range order {
686 repr := fmtscip-go gomod github.com/golang/go/src go1.15 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.15 fmt/Sprint().(k)
687 if s, ok := k.(string); ok {
688 if _, err = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.15 strconv/ParseFloat().(repr, 32); s == "" || err == nil {
689 repr = `"` + repr + `"`
690 }
691 }
692 index := stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Indexscip-go gomod github.com/golang/go/src go1.15 strings/Index().(out, "\n"+repr+":")
693 if index == -1 {
694 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("%#v is not in the output: %#v", k, out)
695 }
696 if index < last {
697 t.Fatalfscip-go gomod github.com/golang/go/src go1.15 testing/common#Fatalf().("%#v was generated before %#v: %q", k, order[i-1], out)
698 }
699 last = index
700 }
701 }
702
703 func newTimescip-go gomod go.yaml.in/yaml/v2 . `go.yaml.in/yaml/v2_test`/newTime().(t timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#) *timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# {
704 return &t
705 }