diff options
Diffstat (limited to 'libgo/go/encoding/xml/xml_test.go')
-rw-r--r-- | libgo/go/encoding/xml/xml_test.go | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/libgo/go/encoding/xml/xml_test.go b/libgo/go/encoding/xml/xml_test.go index 5d5e4bf970..f43a5e7eeb 100644 --- a/libgo/go/encoding/xml/xml_test.go +++ b/libgo/go/encoding/xml/xml_test.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -184,8 +184,6 @@ const nonStrictInput = ` <tag>&0a;</tag> ` -var nonStringEntity = map[string]string{"": "oops!", "0a": "oops!"} - var nonStrictTokens = []Token{ CharData("\n"), StartElement{Name{"", "tag"}, []Attr{}}, @@ -652,10 +650,6 @@ func TestDisallowedCharacters(t *testing.T) { } } -type procInstEncodingTest struct { - expect, got string -} - var procInstTests = []struct { input string expect [2]string @@ -803,3 +797,37 @@ func TestIssue12417(t *testing.T) { } } } + +func TestIssue19333(t *testing.T) { + type X struct { + XMLName Name `xml:"X"` + A int `xml:",attr"` + C int + } + + var tests = []struct { + input string + ok bool + }{ + {`<X></X>`, true}, + {`<X A=""></X>`, true}, + {`<X A="bad"></X>`, true}, + {`<X></X>`, true}, + {`<X><C></C></X>`, false}, + {`<X><C/></X>`, false}, + {`<X><C>bad</C></X>`, false}, + } + + for _, tt := range tests { + err := Unmarshal([]byte(tt.input), new(X)) + if tt.ok { + if err != nil { + t.Errorf("%s: unexpected error: %v", tt.input, err) + } + } else { + if err == nil { + t.Errorf("%s: unexpected success", tt.input) + } + } + } +} |