Skip to content

Commit cfda567

Browse files
Mingundralley
authored andcommitted
Add regression test for #540
1 parent 03deb70 commit cfda567

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/serde-issues.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use pretty_assertions::assert_eq;
66
use quick_xml::de::from_str;
7-
use quick_xml::se::to_string;
7+
use quick_xml::se::{to_string, to_string_with_root};
88
use serde::{Deserialize, Serialize};
99
use std::collections::HashMap;
1010

@@ -335,3 +335,28 @@ mod issue537 {
335335
);
336336
}
337337
}
338+
339+
#[test]
340+
fn issue540() {
341+
#[derive(Serialize)]
342+
pub enum Enum {
343+
Variant {},
344+
}
345+
346+
#[derive(Serialize)]
347+
pub struct Struct {
348+
#[serde(flatten)]
349+
flatten: Enum,
350+
}
351+
352+
assert_eq!(
353+
to_string_with_root(
354+
"root",
355+
&Struct {
356+
flatten: Enum::Variant {},
357+
}
358+
)
359+
.unwrap(),
360+
"<root><Variant/></root>"
361+
);
362+
}

0 commit comments

Comments
 (0)