diff options
Diffstat (limited to 'libgo/go/xml/read_test.go')
-rw-r--r-- | libgo/go/xml/read_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libgo/go/xml/read_test.go b/libgo/go/xml/read_test.go index 2126da3c751..d39c2d52a83 100644 --- a/libgo/go/xml/read_test.go +++ b/libgo/go/xml/read_test.go @@ -369,3 +369,25 @@ var attrStruct = AttrTest{ Bool: true, }, } + +// test data for TestUnmarshalWithoutNameType + +const OK = "OK" +const withoutNameTypeData = ` +<?xml version="1.0" charset="utf-8"?> +<Test3 attr="OK" />` + +type TestThree struct { + XMLName bool `xml:"Test3"` // XMLName field without an xml.Name type + Attr string `xml:"attr"` +} + +func TestUnmarshalWithoutNameType(t *testing.T) { + var x TestThree + if err := Unmarshal(StringReader(withoutNameTypeData), &x); err != nil { + t.Fatalf("Unmarshal: %s", err) + } + if x.Attr != OK { + t.Fatalf("have %v\nwant %v", x.Attr, OK) + } +} |