Debian Codegraph @

internal/libyaml/testdata/node.yaml

raw symbols SCIP
1 # Tests for node.go functions
2 # Testing isZero(), SetString(), shortTag(), longTag(), and Node methods
3
4 # isZero function tests
5 - name: isZero with empty string
6 type: isZero
7 from: ""
8 want: true
9
10 - name: isZero with non-empty string
11 type: isZero
12 from: "hello"
13 want: false
14
15 - name: isZero with zero int
16 type: isZero
17 from: 0
18 want: true
19
20 - name: isZero with non-zero int
21 type: isZero
22 from: 42
23 want: false
24
25 - name: isZero with zero float
26 type: isZero
27 from: 0.0
28 want: true
29
30 - name: isZero with non-zero float
31 type: isZero
32 from: 3.14
33 want: false
34
35 - name: isZero with false bool
36 type: isZero
37 from: false
38 want: true
39
40 - name: isZero with true bool
41 type: isZero
42 from: true
43 want: false
44
45 - name: isZero with nil slice
46 type: isZero
47 from: null
48 want: true
49 also: slice
50
51 - name: isZero with empty slice
52 type: isZero
53 from: []
54 want: true
55
56 - name: isZero with non-empty slice
57 type: isZero
58 from: [1, 2, 3]
59 want: false
60
61 - name: isZero with nil map
62 type: isZero
63 from: null
64 want: true
65 also: map
66
67 - name: isZero with empty map
68 type: isZero
69 from: {}
70 want: true
71
72 - name: isZero with non-empty map
73 type: isZero
74 from: {key: value}
75 want: false
76
77 # SetString method tests
78 - name: SetString with simple ASCII string
79 type: set-string
80 from: "hello world"
81 want:
82 kind: ScalarNode
83 tag: "!!str"
84 value: "hello world"
85 style: plain
86
87 - name: SetString with valid UTF-8 string
88 type: set-string
89 from: "hello 世界"
90 want:
91 kind: ScalarNode
92 tag: "!!str"
93 value: "hello 世界"
94 style: plain
95
96 - name: SetString with multiline string
97 type: set-string
98 from: "line1\nline2\nline3"
99 want:
100 kind: ScalarNode
101 tag: "!!str"
102 value: "line1\nline2\nline3"
103 style: literal
104
105 - name: SetString with multiline containing non-whitespace
106 type: set-string
107 from: "a\nb"
108 want:
109 kind: ScalarNode
110 tag: "!!str"
111 value: "a\nb"
112 style: literal
113
114 - name: SetString with short newline string
115 type: set-string
116 from: "a"
117 want:
118 kind: ScalarNode
119 tag: "!!str"
120 value: "a"
121 style: plain
122
123 - name: SetString with only whitespace and newline
124 type: set-string
125 from: " \n "
126 want:
127 kind: ScalarNode
128 tag: "!!str"
129 value: " \n "
130 style: plain
131
132 - name: SetString with empty string
133 type: set-string
134 from: ""
135 want:
136 kind: ScalarNode
137 tag: "!!str"
138 value: ""
139 style: plain
140
141 - name: SetString with invalid UTF-8
142 type: set-string-binary
143 input_hex: "fffe"
144 want:
145 kind: ScalarNode
146 tag: "!!binary"
147 style: plain
148
149 # shortTag and longTag tests
150 - name: shortTag for standard str tag
151 type: short-tag
152 node:
153 kind: Scalar
154 tag: "tag:yaml.org,2002:str"
155 want: "!!str"
156
157 - name: shortTag for standard int tag
158 type: short-tag
159 node:
160 kind: Scalar
161 tag: "tag:yaml.org,2002:int"
162 want: "!!int"
163
164 - name: shortTag for standard seq tag
165 type: short-tag
166 node:
167 kind: Sequence
168 tag: "tag:yaml.org,2002:seq"
169 want: "!!seq"
170
171 - name: shortTag for standard map tag
172 type: short-tag
173 node:
174 kind: Mapping
175 tag: "tag:yaml.org,2002:map"
176 want: "!!map"
177
178 - name: shortTag for custom long tag
179 type: short-tag
180 node:
181 kind: Scalar
182 tag: "tag:yaml.org,2002:custom"
183 want: "!!custom"
184
185 - name: shortTag for already short tag
186 type: short-tag
187 node:
188 kind: Scalar
189 tag: "!!str"
190 want: "!!str"
191
192 - name: shortTag for custom short tag
193 type: short-tag
194 node:
195 kind: Scalar
196 tag: "!mytag"
197 want: "!mytag"
198
199 - name: shortTag for empty tag on mapping
200 type: short-tag
201 node:
202 kind: Mapping
203 tag: ""
204 want: "!!map"
205
206 - name: shortTag for empty tag on sequence
207 type: short-tag
208 node:
209 kind: Sequence
210 tag: ""
211 want: "!!seq"
212
213 - name: shortTag for empty tag on scalar
214 type: short-tag
215 node:
216 kind: Scalar
217 tag: ""
218 want: "!!str"
219
220 - name: shortTag for quoted scalar
221 type: short-tag
222 node:
223 kind: Scalar
224 tag: ""
225 style: DoubleQuoted
226 want: "!!str"
227
228 - name: longTag for standard str tag
229 type: long-tag
230 node:
231 kind: Scalar
232 tag: "!!str"
233 want: "tag:yaml.org,2002:str"
234
235 - name: longTag for standard int tag
236 type: long-tag
237 node:
238 kind: Scalar
239 tag: "!!int"
240 want: "tag:yaml.org,2002:int"
241
242 - name: longTag for custom short tag
243 type: long-tag
244 node:
245 kind: Scalar
246 tag: "!!custom"
247 want: "tag:yaml.org,2002:custom"
248
249 - name: longTag for already long tag
250 type: long-tag
251 node:
252 kind: Scalar
253 tag: "tag:yaml.org,2002:str"
254 want: "tag:yaml.org,2002:str"
255
256 - name: longTag for non-standard tag
257 type: long-tag
258 node:
259 kind: Scalar
260 tag: "!mytag"
261 want: "!mytag"
262
263 # Node.IsZero tests
264 - name: Node.IsZero on zero node
265 type: node-is-zero
266 node:
267 kind: ""
268 want: true
269
270 - name: Node.IsZero on node with kind
271 type: node-is-zero
272 node:
273 kind: Scalar
274 want: false
275
276 - name: Node.IsZero on node with tag
277 type: node-is-zero
278 node:
279 kind: ""
280 tag: "!!str"
281 want: false
282
283 - name: Node.IsZero on node with value
284 type: node-is-zero
285 node:
286 kind: ""
287 value: "test"
288 want: false
289
290 # shouldUseLiteralStyle helper tests
291 - name: shouldUseLiteralStyle with no newline
292 type: should-literal
293 from: "hello world"
294 want: false
295
296 - name: shouldUseLiteralStyle with newline and content
297 type: should-literal
298 from: "hello\nworld"
299 want: true
300
301 - name: shouldUseLiteralStyle with single char
302 type: should-literal
303 from: "a"
304 want: false
305
306 - name: shouldUseLiteralStyle with newline but length < 2
307 type: should-literal
308 from: "\n"
309 want: false
310
311 - name: shouldUseLiteralStyle with only whitespace
312 type: should-literal
313 from: " \n \n "
314 want: false
315
316 - name: shouldUseLiteralStyle with whitespace and one char
317 type: should-literal
318 from: " a\n "
319 want: true
320
321 - name: shouldUseLiteralStyle with empty string
322 type: should-literal
323 from: ""
324 want: false