diff options
Diffstat (limited to 'libgo/go/encoding/xml/marshal_test.go')
-rw-r--r-- | libgo/go/encoding/xml/marshal_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libgo/go/encoding/xml/marshal_test.go b/libgo/go/encoding/xml/marshal_test.go index bec5376..f23b2cb 100644 --- a/libgo/go/encoding/xml/marshal_test.go +++ b/libgo/go/encoding/xml/marshal_test.go @@ -150,6 +150,10 @@ type XMLNameWithoutTag struct { Value string ",chardata" } +type NameInField struct { + Foo Name `xml:"ns foo"` +} + type AttrTest struct { Int int `xml:",attr"` Lower int `xml:"int,attr"` @@ -483,6 +487,19 @@ var marshalTests = []struct { UnmarshalOnly: true, }, + // xml.Name works in a plain field as well. + { + Value: &NameInField{Name{Space: "ns", Local: "foo"}}, + ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`, + }, + + // Marshaling zero xml.Name uses the tag or field name. + { + Value: &NameInField{}, + ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`, + MarshalOnly: true, + }, + // Test attributes { Value: &AttrTest{ |