Add integration test for rename_all attribute
This commit is contained in:
parent
5890676710
commit
6455801950
|
@ -21,3 +21,23 @@ fn renamed() {
|
||||||
"<renamed renamed=\"true\"></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));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue