Add integration test for rename_all attribute

This commit is contained in:
rsdy 2022-09-26 16:52:29 +01:00 committed by Dirkjan Ochtman
parent 5890676710
commit 6455801950
1 changed files with 20 additions and 0 deletions

View File

@ -21,3 +21,23 @@ fn renamed() {
"<renamed renamed=\"true\"></renamed>"
);
}
#[test]
fn rename_all_struct() {
#[derive(Debug, PartialEq, Eq, ToXml, FromXml)]
#[xml(rename_all = "UPPERCASE")]
pub struct TestStruct {
field_1: String,
#[xml(attribute)]
field_2: bool,
}
let serialized = r#"<TestStruct FIELD_2="true"><FIELD_1>value</FIELD_1></TestStruct>"#;
let instance = TestStruct {
field_1: "value".into(),
field_2: true,
};
assert_eq!(to_string(&instance).unwrap(), serialized);
assert_eq!(from_str::<TestStruct>(serialized), Ok(instance));
}