Skip to content

Commit 586ff2f

Browse files
committed
chore: add test for WithAttrNameSuffix
1 parent 58a2066 commit 586ff2f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

generator_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,30 @@ func TestGenerator(t *testing.T) {
786786
"}",
787787
),
788788
},
789+
{
790+
name: "duplicate_elements_and_attributes",
791+
options: []xmlstruct.GeneratorOption{
792+
xmlstruct.WithAttrNameSuffix("Attr"),
793+
xmlstruct.WithImports(false),
794+
xmlstruct.WithPackageName(""),
795+
xmlstruct.WithHeader(""),
796+
},
797+
xmlStr: joinLines(
798+
`<a>`,
799+
` <b c="1">`,
800+
` <c>d</c>`,
801+
` </b>`,
802+
`</a>`,
803+
),
804+
expectedStr: joinLines(
805+
"type A struct {",
806+
"\tB struct {",
807+
"\t\tCAttr int `xml:\"c,attr\"`",
808+
"\t\tC string `xml:\"c\"`",
809+
"\t} `xml:\"b\"`",
810+
"}",
811+
),
812+
},
789813
} {
790814
t.Run(tc.name, func(t *testing.T) {
791815
t.Parallel()

0 commit comments

Comments
 (0)