Test for sub-table in array table into structs

This commit is contained in:
Thomas Pelletier
2021-03-18 19:48:09 -04:00
parent 548b128e67
commit fad86a5f24
+50
View File
@@ -522,6 +522,56 @@ B = "data"`,
}
},
},
{
desc: "multiple sub-table in array tables into structs",
input: `[[Fruits]]
Name = "apple"
[[Fruits.Varieties]] # nested array of tables
Name = "red delicious"
[[Fruits.Varieties]]
Name = "granny smith"
[[Fruits]]
Name = "banana"
[[Fruits.Varieties]]
Name = "plantain"`,
gen: func() test {
type Variety struct {
Name string
}
type Fruit struct {
Name string
Varieties []Variety
}
type doc struct {
Fruits []Fruit
}
return test{
target: &doc{},
expected: &doc{
Fruits: []Fruit{
{
Name: "apple",
Varieties: []Variety{
{Name: "red delicious"},
{Name: "granny smith"},
},
},
{
Name: "banana",
Varieties: []Variety{
{Name: "plantain"},
},
},
},
},
}
},
},
}
for _, e := range examples {