use similar_asserts::assert_eq; use instant_xml::{from_str, to_string, FromXml, ToXml}; #[derive(Debug, Eq, FromXml, PartialEq, ToXml)] struct Foo { bar: usize, } #[derive(Debug, Eq, FromXml, PartialEq, ToXml)] struct Bar { foo: Vec, baz: Vec, } #[test] fn vec() { let val = Bar { foo: vec![], baz: vec![], }; let xml = ""; assert_eq!(xml, to_string(&val).unwrap()); assert_eq!(val, from_str(xml).unwrap()); let val = Bar { foo: vec![Foo { bar: 42 }], baz: vec!["hello".to_owned()], }; let xml = "42hello"; assert_eq!(xml, to_string(&val).unwrap()); assert_eq!(val, from_str(xml).unwrap()); let val = Bar { foo: vec![Foo { bar: 42 }, Foo { bar: 73 }], baz: vec!["hello".to_owned(), "world".to_owned()], }; let xml = "4273helloworld"; assert_eq!(xml, to_string(&val).unwrap()); assert_eq!(val, from_str(xml).unwrap()); }