Decoder: allow commas in tags (#693)

This commit is contained in:
Thomas Pelletier
2021-11-30 21:59:22 -05:00
committed by GitHub
parent 0d20a84523
commit c862c344b3
2 changed files with 37 additions and 2 deletions
+28
View File
@@ -2698,6 +2698,34 @@ world'`,
}
}
func TestUnmarshalTags(t *testing.T) {
type doc struct {
Dash string `toml:"-,"`
Ignore string `toml:"-"`
A string `toml:"hello"`
B string `toml:"comma,omitempty"`
}
data := `
'-' = "dash"
Ignore = 'me'
hello = 'content'
comma = 'ok'
`
d := doc{}
expected := doc{
Dash: "dash",
Ignore: "",
A: "content",
B: "ok",
}
err := toml.Unmarshal([]byte(data), &d)
require.NoError(t, err)
require.Equal(t, expected, d)
}
func TestASCIIControlCharacters(t *testing.T) {
invalidCharacters := []byte{0x7F}
for c := byte(0x0); c <= 0x08; c++ {