yq/pkg/yqlib/candidate_node_goccy_yaml_test.go
2025-05-15 14:17:47 +02:00

44 lines
581 B
Go

package yqlib
import (
"fmt"
"testing"
"gopkg.in/yaml.v3"
)
func TestMarshalGoccyYAML(t *testing.T) {
input := `
a:
b: 2
c: &anc
d: !mytag ef
e: 3.0
s:
- 1
- 2
`
var yamlNode yaml.Node
err := yaml.Unmarshal([]byte(input), &yamlNode)
if err != nil {
t.Error(err)
return
}
candidate := &CandidateNode{}
err = candidate.UnmarshalYAML(yamlNode.Content[0], make(map[string]*CandidateNode))
if err != nil {
t.Error(err)
return
}
goccyNode, err := candidate.MarshalGoccyYAML()
if err != nil {
t.Error(err)
return
}
fmt.Println(goccyNode)
}