Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Adjusted the test, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Aug 15, 2024
1 parent 812b1fa commit 997d11d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,11 @@ var unmarshalStrictTests = []struct {
data: "a: 1\nc: 2\n",
value: struct{ A, B int }{A: 1},
error: `yaml: unmarshal errors:\n line 2: field c not found in type struct { A int; B int }`,
}, {
known: true,
data: "i: 1\nj: 2\n",
value: customUnmarshaler{I: 2},
error: `yaml: unmarshal errors:\n line 1: field i not found in type yaml_test.bufT`,
}, {
unique: true,
data: "a: 1\nb: 2\na: 3\n",
Expand Down Expand Up @@ -1713,6 +1718,22 @@ func (t *textUnmarshaler) UnmarshalText(s []byte) error {
return nil
}

type customUnmarshaler struct {
I int
}

func (c *customUnmarshaler) UnmarshalYAML(value *yaml.Node) error {
type bufT struct {
J int
}
var buf bufT
if err := value.Decode(&buf); err != nil {
return err
}
c.I = buf.J
return nil
}

func (s *S) TestFuzzCrashers(c *C) {
cases := []string{
// runtime error: index out of range
Expand Down

0 comments on commit 997d11d

Please sign in to comment.