]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/xml: add generic encoding test
authorKeith Randall <khr@golang.org>
Tue, 12 Oct 2021 23:50:35 +0000 (16:50 -0700)
committerKeith Randall <khr@golang.org>
Tue, 9 Nov 2021 21:26:25 +0000 (21:26 +0000)
Fixes #48521

Change-Id: Id8402bcff243c0ab19e4ec0b138b9af8c111f88d
Reviewed-on: https://go-review.googlesource.com/c/go/+/355492
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/encoding/xml/marshal_test.go

index d2e5137afd7c05a7ad0ad1414e227f168ee4bf54..cb95905f5b83ab56f3a3e230f2ca0823d47ec33f 100644 (file)
@@ -524,6 +524,10 @@ type IfaceAny struct {
        T2  T2
 }
 
+type Generic[T any] struct {
+       X T
+}
+
 var (
        nameAttr     = "Sarah"
        ageAttr      = uint(12)
@@ -641,6 +645,7 @@ var marshalTests = []struct {
        {Value: &Particle{HasMass: true}, ExpectXML: `<particle>true</particle>`},
        {Value: &Departure{When: ParseTime("2013-01-09T00:15:00-09:00")}, ExpectXML: `<departure>2013-01-09T00:15:00-09:00</departure>`},
        {Value: atomValue, ExpectXML: atomXML},
+       {Value: &Generic[int]{1}, ExpectXML: `<Generic><X>1</X></Generic>`},
        {
                Value: &Ship{
                        Name:  "Heart of Gold",