aboutsummaryrefslogtreecommitdiff
path: root/vendor/gopkg.in/yaml.v2/decode_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-08-28 17:49:28 +0200
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2017-08-28 08:49:28 -0700
commit7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201 (patch)
tree2734029ca19d1a21794ffc65299c0d57254f5352 /vendor/gopkg.in/yaml.v2/decode_test.go
parent558f4bea41e0493dd4b0e6d0f73b0220a39d1e67 (diff)
downloadcoredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.tar.gz
coredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.tar.zst
coredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.zip
dep ensure -update (#1001)
* dep ensure -update Run "dep ensure -update` to update all dependencies. No code changes; just the dependencies. * dep prune * add new venderod
Diffstat (limited to 'vendor/gopkg.in/yaml.v2/decode_test.go')
-rw-r--r--vendor/gopkg.in/yaml.v2/decode_test.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/vendor/gopkg.in/yaml.v2/decode_test.go b/vendor/gopkg.in/yaml.v2/decode_test.go
index a6fea0f20..713b1ee9c 100644
--- a/vendor/gopkg.in/yaml.v2/decode_test.go
+++ b/vendor/gopkg.in/yaml.v2/decode_test.go
@@ -405,6 +405,12 @@ var unmarshalTests = []struct {
map[string]interface{}{"v": 1},
},
+ // Non-specific tag (Issue #75)
+ {
+ "v: ! test",
+ map[string]interface{}{"v": "test"},
+ },
+
// Anchors and aliases.
{
"a: &x 1\nb: &y 2\nc: *x\nd: *y\n",
@@ -604,7 +610,8 @@ type inlineC struct {
}
func (s *S) TestUnmarshal(c *C) {
- for _, item := range unmarshalTests {
+ for i, item := range unmarshalTests {
+ c.Logf("test %d: %q", i, item.data)
t := reflect.ValueOf(item.value).Type()
var value interface{}
switch t.Kind() {
@@ -648,6 +655,7 @@ var unmarshalErrorTests = []struct {
{"a: !!binary ==", "yaml: !!binary value contains invalid base64 data"},
{"{[.]}", `yaml: invalid map key: \[\]interface \{\}\{"\."\}`},
{"{{.}}", `yaml: invalid map key: map\[interface\ \{\}\]interface \{\}\{".":interface \{\}\(nil\)\}`},
+ {"%TAG !%79! tag:yaml.org,2002:\n---\nv: !%79!int '1'", "yaml: did not find expected whitespace"},
}
func (s *S) TestUnmarshalErrors(c *C) {
@@ -968,6 +976,17 @@ func (s *S) TestUnmarshalSliceOnPreset(c *C) {
c.Assert(v.A, DeepEquals, []int{2})
}
+func (s *S) TestUnmarshalStrict(c *C) {
+ v := struct{ A, B int }{}
+
+ err := yaml.UnmarshalStrict([]byte("a: 1\nb: 2"), &v)
+ c.Check(err, IsNil)
+ err = yaml.Unmarshal([]byte("a: 1\nb: 2\nc: 3"), &v)
+ c.Check(err, IsNil)
+ err = yaml.UnmarshalStrict([]byte("a: 1\nb: 2\nc: 3"), &v)
+ c.Check(err, ErrorMatches, "yaml: unmarshal errors:\n line 1: field c not found in struct struct { A int; B int }")
+}
+
//var data []byte
//func init() {
// var err error