MCPcopy
hub / github.com/carvel-dev/ytt / TestParserRootValue

Function TestParserRootValue

pkg/yamlmeta/parser_test.go:157–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestParserRootValue(t *testing.T) {
158 parserExamples{
159 {Description: "string", Data: "abc",
160 Expected: yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
161 Items: []*yamlmeta.DocumentProto{
162 &yamlmeta.DocumentProto{
163 Value: "abc",
164 Position: filepos.NewPosition(1),
165 },
166 },
167 Position: filepos.NewUnknownPosition(),
168 }),
169 },
170 {Description: "integer", Data: "1",
171 Expected: yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
172 Items: []*yamlmeta.DocumentProto{
173 &yamlmeta.DocumentProto{
174 Value: 1,
175 Position: filepos.NewPosition(1),
176 },
177 },
178 Position: filepos.NewUnknownPosition(),
179 }),
180 },
181 {Description: "float", Data: "2000.1",
182 Expected: yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
183 Items: []*yamlmeta.DocumentProto{
184 &yamlmeta.DocumentProto{
185 Value: 2000.1,
186 Position: filepos.NewPosition(1),
187 },
188 },
189 Position: filepos.NewUnknownPosition(),
190 }),
191 },
192 {Description: "float (exponent)", Data: "9e3",
193 Expected: yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
194 Items: []*yamlmeta.DocumentProto{
195 &yamlmeta.DocumentProto{
196 Value: 9000.0,
197 Position: filepos.NewPosition(1),
198 },
199 },
200 Position: filepos.NewUnknownPosition(),
201 }),
202 },
203 {Description: "array", Data: "- 1",
204 Expected: yamlmeta.NewDocumentSet(&yamlmeta.DocumentSetProto{
205 Items: []*yamlmeta.DocumentProto{
206 &yamlmeta.DocumentProto{
207 Value: &yamlmeta.ArrayProto{
208 Items: []*yamlmeta.ArrayItemProto{
209 &yamlmeta.ArrayItemProto{Value: 1, Position: filepos.NewPosition(1)},
210 },
211 Position: filepos.NewPosition(1),
212 },
213 Position: filepos.NewPosition(1),
214 },

Callers

nothing calls this directly

Calls 4

NewDocumentSetFunction · 0.92
NewPositionFunction · 0.92
NewUnknownPositionFunction · 0.92
CheckMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…