Skip to content

Commit add7406

Browse files
Mingundralley
authored andcommitted
Add regression test for #500
1 parent 12b688c commit add7406

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/serde-issues.rs

+62
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,68 @@ fn issue429() {
179179
);
180180
}
181181

182+
/// Regression test for https://github.com/tafia/quick-xml/issues/500.
183+
#[test]
184+
fn issue500() {
185+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
186+
struct TagOne {}
187+
188+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
189+
struct TagTwo {}
190+
191+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
192+
enum Tag {
193+
TagOne(TagOne),
194+
TagTwo(TagTwo),
195+
}
196+
197+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
198+
struct Root {
199+
#[serde(rename = "$value", default)]
200+
data: Vec<Tag>,
201+
}
202+
203+
let data: Root = from_str(
204+
"\
205+
<root>\
206+
<TagOne></TagOne>\
207+
<TagTwo></TagTwo>\
208+
<TagOne></TagOne>\
209+
</root>\
210+
",
211+
)
212+
.unwrap();
213+
214+
assert_eq!(
215+
data,
216+
Root {
217+
data: vec![
218+
Tag::TagOne(TagOne {}),
219+
Tag::TagTwo(TagTwo {}),
220+
Tag::TagOne(TagOne {}),
221+
],
222+
}
223+
);
224+
225+
let data: Vec<Tag> = from_str(
226+
"\
227+
<TagOne></TagOne>\
228+
<TagTwo></TagTwo>\
229+
<TagOne></TagOne>\
230+
",
231+
)
232+
.unwrap();
233+
234+
assert_eq!(
235+
data,
236+
vec![
237+
Tag::TagOne(TagOne {}),
238+
Tag::TagTwo(TagTwo {}),
239+
Tag::TagOne(TagOne {}),
240+
]
241+
);
242+
}
243+
182244
/// Regression test for https://github.com/tafia/quick-xml/issues/537.
183245
///
184246
/// This test checks that special `xmlns:xxx` attributes uses full name of

0 commit comments

Comments
 (0)