unmarshal: validate date (#622)

This commit is contained in:
Johanan Idicula
2021-10-17 20:18:20 -04:00
committed by GitHub
parent 85f5d567e4
commit 76f53c857b
3 changed files with 65 additions and 1 deletions
+26
View File
@@ -353,6 +353,22 @@ func TestUnmarshal(t *testing.T) {
}
},
},
{
desc: "local leap-day date into interface",
input: `a = 2020-02-29`,
gen: func() test {
type doc struct {
A interface{}
}
return test{
target: &doc{},
expected: &doc{
A: toml.LocalDate{2020, 2, 29},
},
}
},
},
{
desc: "local-time with nano second",
input: `a = 12:08:05.666666666`,
@@ -2091,6 +2107,16 @@ world'`,
desc: "multiline basic string with unfinished escape sequence after the first escape code",
data: "a = \"\"\"\\t\\",
},
{
desc: `impossible date-day`,
data: `A = 2021-03-40T23:59:00`,
msg: `impossible date`,
},
{
desc: `leap day in non-leap year`,
data: `A = 2021-02-29T23:59:00`,
msg: `impossible date`,
},
}
for _, e := range examples {