Skip to content

Commit 12b688c

Browse files
Mingundralley
authored andcommitted
Add regression test for #429
1 parent c6270f6 commit 12b688c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/serde-issues.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,43 @@ fn issue349() {
142142
);
143143
}
144144

145+
/// Regression test for https://github.com/tafia/quick-xml/issues/429.
146+
#[test]
147+
fn issue429() {
148+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
149+
enum State {
150+
A,
151+
B,
152+
C,
153+
}
154+
155+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
156+
struct StateOuter {
157+
#[serde(rename = "$text")]
158+
state: State,
159+
}
160+
161+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
162+
pub struct Root {
163+
state: StateOuter,
164+
}
165+
166+
assert_eq!(
167+
from_str::<Root>("<root><state>B</state></root>").unwrap(),
168+
Root {
169+
state: StateOuter { state: State::B }
170+
}
171+
);
172+
173+
assert_eq!(
174+
to_string(&Root {
175+
state: StateOuter { state: State::B }
176+
})
177+
.unwrap(),
178+
"<Root><state>B</state></Root>"
179+
);
180+
}
181+
145182
/// Regression test for https://github.com/tafia/quick-xml/issues/537.
146183
///
147184
/// This test checks that special `xmlns:xxx` attributes uses full name of

0 commit comments

Comments
 (0)