mirror of
https://github.com/goccy/go-yaml.git
synced 2025-12-08 06:09:57 +00:00
Prevent panic when decoding string named types (#743)
This commit is contained in:
parent
04f9bb53f7
commit
6a6c998c2f
2 changed files with 26 additions and 7 deletions
|
|
@ -25,6 +25,8 @@ type Child struct {
|
|||
C int `yaml:"-"`
|
||||
}
|
||||
|
||||
type TestString string
|
||||
|
||||
func TestDecoder(t *testing.T) {
|
||||
tests := []struct {
|
||||
source string
|
||||
|
|
@ -35,6 +37,10 @@ func TestDecoder(t *testing.T) {
|
|||
source: "v: hi\n",
|
||||
value: map[string]string{"v": "hi"},
|
||||
},
|
||||
{
|
||||
source: "v: hi\n",
|
||||
value: map[string]TestString{"v": "hi"},
|
||||
},
|
||||
{
|
||||
source: "v: \"true\"\n",
|
||||
value: map[string]string{"v": "true"},
|
||||
|
|
@ -55,6 +61,10 @@ func TestDecoder(t *testing.T) {
|
|||
source: "v: 10\n",
|
||||
value: map[string]string{"v": "10"},
|
||||
},
|
||||
{
|
||||
source: "v: 10\n",
|
||||
value: map[string]TestString{"v": "10"},
|
||||
},
|
||||
{
|
||||
source: "v: -10\n",
|
||||
value: map[string]string{"v": "-10"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue