Debian Codegraph @

parsing/kdl/cross_format_test.go

raw symbols SCIP
1 package kdl_testscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/
2
3 import (
4 "stringsscip-go gomod github.com/golang/go/src go1.25 strings/"
5 "testingscip-go gomod github.com/golang/go/src go1.25 testing/"
6
7 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
8 "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/"
9 "github.com/tomwright/dasel/v3/parsing/jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/"
10 "github.com/tomwright/dasel/v3/parsing/kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/"
11 "github.com/tomwright/dasel/v3/parsing/yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/"
12 )
13
14 func mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, f parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Formatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Format#) parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Readerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader# {
15 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
16 r, err := f.NewReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Format#NewReader().(parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.DefaultReaderOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/DefaultReaderOptions().())
17 if err != nil {
18 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
19 }
20 return r
21 }
22
23 func mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, f parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Formatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Format#) parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Writerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer# {
24 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
25 w, err := f.NewWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Format#NewWriter().(parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.DefaultWriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/DefaultWriterOptions().())
26 if err != nil {
27 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
28 }
29 return w
30 }
31
32 // --- KDL → JSON ---
33
34 func TestKDLToJSON_Scalarsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_Scalars().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
35 kdlData := []byte(`name "Bob"
36 age 76
37 active true
38 score 9.5`)
39
40 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
41 if err != nil {
42 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
43 }
44
45 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
46 if err != nil {
47 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
48 }
49
50 result := string(jsonData)
51 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"name": "Bob"`)
52 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"age": 76`)
53 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"active": true`)
54 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"score": 9.5`)
55 }
56
57 func TestKDLToJSON_NestedChildrenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_NestedChildren().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
58 kdlData := []byte(`server {
59 host "localhost"
60 port 8080
61 }`)
62
63 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
64 if err != nil {
65 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
66 }
67
68 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
69 if err != nil {
70 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
71 }
72
73 result := string(jsonData)
74 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"server"`)
75 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"host": "localhost"`)
76 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"port": 8080`)
77 }
78
79 func TestKDLToJSON_DuplicateNodesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_DuplicateNodes().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
80 kdlData := []byte(`plugin "git"
81 plugin "docker"
82 plugin "tmux"`)
83
84 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
85 if err != nil {
86 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
87 }
88
89 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
90 if err != nil {
91 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
92 }
93
94 result := string(jsonData)
95 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"plugin"`)
96 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"git"`)
97 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"docker"`)
98 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"tmux"`)
99 }
100
101 func TestKDLToJSON_NullAndBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_NullAndBool().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
102 kdlData := []byte(`enabled #true
103 disabled #false
104 empty #null`)
105
106 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
107 if err != nil {
108 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
109 }
110
111 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
112 if err != nil {
113 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
114 }
115
116 result := string(jsonData)
117 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"enabled": true`)
118 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"disabled": false`)
119 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"empty": null`)
120 }
121
122 func TestKDLToJSON_NodeWithArgsAndPropsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_NodeWithArgsAndProps().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
123 kdlData := []byte(`server 80 host="localhost" {
124 tls #true
125 }`)
126
127 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
128 if err != nil {
129 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
130 }
131
132 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
133 if err != nil {
134 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
135 }
136
137 result := string(jsonData)
138 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"server"`)
139 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"$args"`)
140 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `80`)
141 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"host": "localhost"`)
142 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"tls": true`)
143 }
144
145 func TestKDLToJSON_EmptyNodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_EmptyNode().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
146 kdlData := []byte(`marker`)
147
148 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
149 if err != nil {
150 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
151 }
152
153 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
154 if err != nil {
155 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
156 }
157
158 result := string(jsonData)
159 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"marker": null`)
160 }
161
162 func TestKDLToJSON_DeeplyNestedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_DeeplyNested().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
163 kdlData := []byte(`a {
164 b {
165 c "deep"
166 }
167 }`)
168
169 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
170 if err != nil {
171 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
172 }
173
174 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
175 if err != nil {
176 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
177 }
178
179 result := string(jsonData)
180 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"a"`)
181 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"b"`)
182 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"c": "deep"`)
183 }
184
185 func TestKDLToJSON_NumberTypesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_NumberTypes().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
186 kdlData := []byte(`hex 0xff
187 octal 0o77
188 binary 0b1010
189 big 1_000_000`)
190
191 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
192 if err != nil {
193 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
194 }
195
196 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
197 if err != nil {
198 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
199 }
200
201 result := string(jsonData)
202 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"hex": 255`)
203 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"octal": 63`)
204 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"binary": 10`)
205 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"big": 1000000`)
206 }
207
208 // --- JSON → KDL ---
209
210 func TestJSONToKDL_SimpleObjectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestJSONToKDL_SimpleObject().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
211 jsonData := []byte(`{
212 "name": "Bob",
213 "age": 76,
214 "active": true
215 }
216 `)
217
218 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
219 if err != nil {
220 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
221 }
222
223 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
224 if err != nil {
225 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
226 }
227
228 result := string(kdlData)
229 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `name "Bob"`)
230 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `age 76`)
231 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `active #true`)
232 }
233
234 func TestJSONToKDL_NestedObjectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestJSONToKDL_NestedObject().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
235 jsonData := []byte(`{
236 "server": {
237 "host": "localhost",
238 "port": 8080
239 }
240 }
241 `)
242
243 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
244 if err != nil {
245 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
246 }
247
248 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
249 if err != nil {
250 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
251 }
252
253 result := string(kdlData)
254 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "server")
255 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `host="localhost"`)
256 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `port=8080`)
257 }
258
259 func TestJSONToKDL_Arrayscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestJSONToKDL_Array().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
260 jsonData := []byte(`{
261 "plugins": [
262 "git",
263 "docker"
264 ]
265 }
266 `)
267
268 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
269 if err != nil {
270 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
271 }
272
273 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
274 if err != nil {
275 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
276 }
277
278 result := string(kdlData)
279 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Countscip-go gomod github.com/golang/go/src go1.25 strings/Count().(result, "plugins") != 2 {
280 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected 2 'plugins' nodes, got:\n%s", result)
281 }
282 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"git"`)
283 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"docker"`)
284 }
285
286 func TestJSONToKDL_NullAndBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestJSONToKDL_NullAndBool().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
287 jsonData := []byte(`{
288 "enabled": true,
289 "disabled": false,
290 "empty": null
291 }
292 `)
293
294 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
295 if err != nil {
296 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
297 }
298
299 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
300 if err != nil {
301 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
302 }
303
304 result := string(kdlData)
305 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "enabled #true")
306 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "disabled #false")
307 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "empty")
308 }
309
310 // --- KDL → YAML ---
311
312 func TestKDLToYAML_Scalarsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToYAML_Scalars().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
313 kdlData := []byte(`name "Bob"
314 age 76
315 active true`)
316
317 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
318 if err != nil {
319 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
320 }
321
322 yamlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
323 if err != nil {
324 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
325 }
326
327 result := string(yamlData)
328 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "name: Bob")
329 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "age: 76")
330 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "active: true")
331 }
332
333 func TestKDLToYAML_Nestedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToYAML_Nested().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
334 kdlData := []byte(`database {
335 host "db.example.com"
336 port 5432
337 }`)
338
339 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
340 if err != nil {
341 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
342 }
343
344 yamlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
345 if err != nil {
346 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
347 }
348
349 result := string(yamlData)
350 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "database:")
351 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "host: db.example.com")
352 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "port: 5432")
353 }
354
355 // --- YAML → KDL ---
356
357 func TestYAMLToKDL_SimpleMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestYAMLToKDL_SimpleMap().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
358 yamlData := []byte(`name: Bob
359 age: 76
360 active: true
361 `)
362
363 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(yamlData)
364 if err != nil {
365 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
366 }
367
368 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
369 if err != nil {
370 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
371 }
372
373 result := string(kdlData)
374 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `name "Bob"`)
375 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `age 76`)
376 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `active #true`)
377 }
378
379 func TestYAMLToKDL_NestedMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestYAMLToKDL_NestedMap().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
380 yamlData := []byte(`database:
381 host: db.example.com
382 port: 5432
383 `)
384
385 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(yamlData)
386 if err != nil {
387 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
388 }
389
390 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
391 if err != nil {
392 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
393 }
394
395 result := string(kdlData)
396 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "database")
397 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `host="db.example.com"`)
398 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `port=5432`)
399 }
400
401 // --- Round-trips via intermediate model ---
402
403 func TestRoundTrip_KDLToJSONToKDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestRoundTrip_KDLToJSONToKDL().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
404 kdlInput := []byte(`name "Bob"
405 age 76
406 active #true`)
407
408 // KDL → model
409 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlInput)
410 if err != nil {
411 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
412 }
413
414 // model → JSON
415 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
416 if err != nil {
417 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
418 }
419
420 // JSON → model
421 val2, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
422 if err != nil {
423 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
424 }
425
426 // model → KDL
427 kdlOutput, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val2)
428 if err != nil {
429 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
430 }
431
432 // Verify the KDL output can be re-read and has same values
433 val3, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlOutput)
434 if err != nil {
435 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
436 }
437
438 assertModelStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelString().(t, val3, "name", "Bob")
439 assertModelIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelInt().(t, val3, "age", 76)
440 assertModelBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelBool().(t, val3, "active", true)
441 }
442
443 func TestRoundTrip_JSONToKDLToJSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestRoundTrip_JSONToKDLToJSON().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
444 jsonInput := []byte(`{
445 "name": "Alice",
446 "count": 42,
447 "enabled": false
448 }
449 `)
450
451 // JSON → model
452 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonInput)
453 if err != nil {
454 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
455 }
456
457 // model → KDL
458 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
459 if err != nil {
460 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
461 }
462
463 // KDL → model
464 val2, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
465 if err != nil {
466 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
467 }
468
469 // model → JSON
470 jsonOutput, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val2)
471 if err != nil {
472 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
473 }
474
475 result := string(jsonOutput)
476 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"name": "Alice"`)
477 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"count": 42`)
478 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"enabled": false`)
479 }
480
481 func TestRoundTrip_YAMLToKDLToYAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestRoundTrip_YAMLToKDLToYAML().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
482 yamlInput := []byte(`name: Alice
483 count: 42
484 enabled: false
485 `)
486
487 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(yamlInput)
488 if err != nil {
489 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
490 }
491
492 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
493 if err != nil {
494 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
495 }
496
497 val2, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
498 if err != nil {
499 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
500 }
501
502 yamlOutput, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val2)
503 if err != nil {
504 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
505 }
506
507 result := string(yamlOutput)
508 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "name: Alice")
509 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "count: 42")
510 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "enabled: false")
511 }
512
513 func TestRoundTrip_KDLToYAMLToKDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestRoundTrip_KDLToYAMLToKDL().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
514 kdlInput := []byte(`title "My App"
515 version 3
516 debug #false`)
517
518 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlInput)
519 if err != nil {
520 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
521 }
522
523 yamlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
524 if err != nil {
525 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
526 }
527
528 val2, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, yamlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/.YAMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/yaml`/YAML.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(yamlData)
529 if err != nil {
530 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
531 }
532
533 kdlOutput, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val2)
534 if err != nil {
535 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
536 }
537
538 val3, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlOutput)
539 if err != nil {
540 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
541 }
542
543 assertModelStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelString().(t, val3, "title", "My App")
544 assertModelIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelInt().(t, val3, "version", 3)
545 assertModelBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelBool().(t, val3, "debug", false)
546 }
547
548 // --- Real-world config conversions ---
549
550 func TestKDLToJSON_ZellijLikeConfigscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_ZellijLikeConfig().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
551 kdlData := []byte(`keybinds {
552 normal {
553 bind "Ctrl+h" {
554 action "MoveFocus" "Left"
555 }
556 }
557 }
558 theme "dracula"
559 pane_frames true`)
560
561 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
562 if err != nil {
563 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
564 }
565
566 jsonData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
567 if err != nil {
568 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
569 }
570
571 result := string(jsonData)
572 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"keybinds"`)
573 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"theme": "dracula"`)
574 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `"pane_frames": true`)
575 }
576
577 func TestJSONToKDL_PackageConfigscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestJSONToKDL_PackageConfig().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
578 jsonData := []byte(`{
579 "name": "my-app",
580 "version": "1.0.0",
581 "private": true,
582 "dependencies": {
583 "react": "^18.0.0",
584 "typescript": "^5.0.0"
585 }
586 }
587 `)
588
589 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, jsonscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/.JSONscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/json`/JSON.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(jsonData)
590 if err != nil {
591 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
592 }
593
594 kdlData, err := mustWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustWriter().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#Write.(val)
595 if err != nil {
596 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
597 }
598
599 result := string(kdlData)
600 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `name "my-app"`)
601 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, `version "1.0.0"`)
602 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "private #true")
603 assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t, result, "dependencies")
604 }
605
606 // --- CLI-level cross-format (KDL added to existing patterns) ---
607
608 func TestKDLToJSON_SelectScalarscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/TestKDLToJSON_SelectScalar().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
609 kdlData := []byte(`greeting "hello"
610 count 42`)
611
612 val, err := mustReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/mustReader().(t, kdlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/.KDLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl`/KDL.).Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#Read.(kdlData)
613 if err != nil {
614 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
615 }
616
617 // Query-like: access a specific key
618 v, err := val.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().("greeting")
619 if err != nil {
620 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
621 }
622 s, err := v.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().()
623 if err != nil {
624 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
625 }
626 if s != "hello" {
627 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected 'hello', got %q", s)
628 }
629
630 v2, err := val.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().("count")
631 if err != nil {
632 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
633 }
634 n, err := v2.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().()
635 if err != nil {
636 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
637 }
638 if n != 42 {
639 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected 42, got %d", n)
640 }
641 }
642
643 // --- Helpers ---
644
645 func assertContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertContains().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, haystack, needle string) {
646 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
647 if !stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Containsscip-go gomod github.com/golang/go/src go1.25 strings/Contains().(haystack, needle) {
648 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected output to contain %q, got:\n%s", needle, haystack)
649 }
650 }
651
652 func assertModelStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelString().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, val *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, key, expected string) {
653 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
654 v, err := val.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key)
655 if err != nil {
656 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q: %v", key, err)
657 }
658 s, err := v.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().()
659 if err != nil {
660 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q string: %v", key, err)
661 }
662 if s != expected {
663 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("key %q: expected %q, got %q", key, expected, s)
664 }
665 }
666
667 func assertModelIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelInt().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, val *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, key string, expected int64) {
668 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
669 v, err := val.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key)
670 if err != nil {
671 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q: %v", key, err)
672 }
673 n, err := v.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().()
674 if err != nil {
675 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q int: %v", key, err)
676 }
677 if n != expected {
678 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("key %q: expected %d, got %d", key, expected, n)
679 }
680 }
681
682 func assertModelBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/kdl_test`/assertModelBool().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, val *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, key string, expected bool) {
683 t.Helperscip-go gomod github.com/golang/go/src go1.25 testing/common#Helper().()
684 v, err := val.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key)
685 if err != nil {
686 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q: %v", key, err)
687 }
688 b, err := v.BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().()
689 if err != nil {
690 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("key %q bool: %v", key, err)
691 }
692 if b != expected {
693 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("key %q: expected %v, got %v", key, expected, b)
694 }
695 }