1 mod common;
2
3 use common::init_logger;
4 use log::info;
5 use serde::Deserialize;
6 use serde_xml_rs::from_str;
7
8 #[derive(Debug, Deserialize, PartialEq)]
9 struct Item {
10 name: String,
11 source: String,
12 }
13
14 #[test]
simple_struct_from_attributes_should_fail()15 fn simple_struct_from_attributes_should_fail() {
16 init_logger();
17
18 let s = r##"
19 <item name="hello" source="world.rs />
20 "##;
21
22 let item: Result<Item, _> = from_str(s);
23 match item {
24 Ok(_) => assert!(false),
25 Err(e) => {
26 info!("simple_struct_from_attributes_should_fail(): {}", e);
27 assert!(true)
28 }
29 }
30 }
31
32 #[test]
multiple_roots_attributes_should_fail()33 fn multiple_roots_attributes_should_fail() {
34 init_logger();
35
36 let s = r##"
37 <item name="hello" source="world.rs" />
38 <item name="hello source="world.rs" />
39 "##;
40
41 let item: Result<Vec<Item>, _> = from_str(s);
42 match item {
43 Ok(_) => assert!(false),
44 Err(e) => {
45 info!("multiple_roots_attributes_should_fail(): {}", e);
46 assert!(true)
47 }
48 }
49 }
50