encoder: inline tables create map in nil interface (#496)
Co-authored-by: Thomas Pelletier <pelletier.thomas@gmail.com>
This commit is contained in:
+24
-1
@@ -296,6 +296,17 @@ B = "data"`,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "standard empty table",
|
||||
input: `[A]`,
|
||||
gen: func() test {
|
||||
var v map[string]interface{}
|
||||
return test{
|
||||
target: &v,
|
||||
expected: &map[string]interface{}{`A`: map[string]interface{}{}},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "inline table",
|
||||
input: `Name = {First = "hello", Last = "world"}`,
|
||||
@@ -316,6 +327,17 @@ B = "data"`,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "inline empty table",
|
||||
input: `A = {}`,
|
||||
gen: func() test {
|
||||
var v map[string]interface{}
|
||||
return test{
|
||||
target: &v,
|
||||
expected: &map[string]interface{}{`A`: map[string]interface{}{}},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "inline table inside array",
|
||||
input: `Names = [{First = "hello", Last = "world"}, {First = "ab", Last = "cd"}]`,
|
||||
@@ -713,6 +735,7 @@ type Integer484 struct {
|
||||
func (i Integer484) MarshalText() ([]byte, error) {
|
||||
return []byte(strconv.Itoa(i.Value)), nil
|
||||
}
|
||||
|
||||
func (i *Integer484) UnmarshalText(data []byte) error {
|
||||
conv, err := strconv.Atoi(string(data))
|
||||
if err != nil {
|
||||
@@ -895,7 +918,7 @@ func TestIssue287(t *testing.T) {
|
||||
expected := map[string]interface{}{
|
||||
"y": []interface{}{
|
||||
[]interface{}{
|
||||
nil,
|
||||
map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user