(t *testing.T)
| 259 | } |
| 260 | |
| 261 | func TestParserMapArray(t *testing.T) { |
| 262 | const data = `--- |
| 263 | array: |
| 264 | - 1 |
| 265 | - 2 |
| 266 | - key: value |
| 267 | ` |
| 268 | |
| 269 | parsedVal, err := yamlmeta.NewParser(yamlmeta.ParserOpts{WithoutComments: false}).ParseBytes([]byte(data), "") |
| 270 | if err != nil { |
| 271 | t.Fatalf("error: %s", err) |
| 272 | } |
| 273 | |
| 274 | expectedVal := yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{ |
| 275 | Items: []*yamlmeta.DocumentProto{ |
| 276 | &yamlmeta.DocumentProto{ |
| 277 | Value: &yamlmeta.MapProto{ |
| 278 | Items: []*yamlmeta.MapItemProto{ |
| 279 | &yamlmeta.MapItemProto{ |
| 280 | Key: "array", |
| 281 | Value: &yamlmeta.ArrayProto{ |
| 282 | Items: []*yamlmeta.ArrayItemProto{ |
| 283 | &yamlmeta.ArrayItemProto{Value: 1, Position: filepos.NewPosition(3)}, |
| 284 | &yamlmeta.ArrayItemProto{Value: 2, Position: filepos.NewPosition(4)}, |
| 285 | &yamlmeta.ArrayItemProto{ |
| 286 | Value: &yamlmeta.MapProto{ |
| 287 | Items: []*yamlmeta.MapItemProto{ |
| 288 | &yamlmeta.MapItemProto{ |
| 289 | Key: "key", |
| 290 | Value: "value", |
| 291 | Position: filepos.NewPosition(5), |
| 292 | }, |
| 293 | }, |
| 294 | Position: filepos.NewPosition(5), |
| 295 | }, |
| 296 | Position: filepos.NewPosition(5), |
| 297 | }, |
| 298 | }, |
| 299 | Position: filepos.NewPosition(2), |
| 300 | }, |
| 301 | Position: filepos.NewPosition(2), |
| 302 | }, |
| 303 | }, |
| 304 | Position: filepos.NewPosition(1), |
| 305 | }, |
| 306 | Position: filepos.NewPosition(1), |
| 307 | }, |
| 308 | }, |
| 309 | Position: filepos.NewUnknownPosition(), |
| 310 | }) |
| 311 | |
| 312 | printer := yamlmeta.NewPrinterWithOpts(nil, yamlmeta.PrinterOpts{ExcludeRefs: true}) |
| 313 | |
| 314 | parsedValStr := printer.PrintStr(parsedVal) |
| 315 | expectedValStr := printer.PrintStr(expectedVal) |
| 316 | |
| 317 | assertEqual(t, parsedValStr, expectedValStr) |
| 318 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…