Skip to content

Commit

Permalink
Add test for []interface{} reset
Browse files Browse the repository at this point in the history
  • Loading branch information
pelletier committed Feb 27, 2024
1 parent cd63267 commit 78ad639
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions unmarshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,32 @@ func TestIssue931(t *testing.T) {
require.Equal(t, items{[]item{{"c"}, {"d"}}}, its)
}

func TestIssue931Interface(t *testing.T) {
type items struct {
Slice []interface{}
}

type item = map[string]interface{}

its := items{
[]interface{}{
item{"Name": "a"},
item{"Name": "b"},
},
}

b := []byte(`
[[Slice]]
Name = 'c'
[[Slice]]
Name = 'd'
`)

toml.Unmarshal(b, &its)
require.Equal(t, items{[]interface{}{item{"Name": "c"}, item{"Name": "d"}}}, its)
}

func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {
desc string
Expand Down

0 comments on commit 78ad639

Please sign in to comment.