message: Fix wrong parsing of the <body/> element, and add a test for it.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-07 15:06:11 +01:00
parent 4278c8ce2b
commit da31e72357

View file

@ -166,7 +166,7 @@ impl<'a> TryFrom<&'a Element> for Message {
to: to, to: to,
id: id, id: id,
type_: type_, type_: type_,
bodies: BTreeMap::new(), bodies: bodies,
subjects: subjects, subjects: subjects,
payloads: payloads, payloads: payloads,
}) })
@ -263,7 +263,11 @@ mod tests {
#[test] #[test]
fn test_body() { fn test_body() {
let elem: Element = "<message xmlns='jabber:client' to='coucou@example.org' type='chat'><body>Hello world!</body></message>".parse().unwrap(); let elem: Element = "<message xmlns='jabber:client' to='coucou@example.org' type='chat'><body>Hello world!</body></message>".parse().unwrap();
Message::try_from(&elem).unwrap(); let message = Message::try_from(&elem).unwrap();
assert_eq!(message.bodies[""], "Hello world!");
let elem2 = (&message).into();
assert_eq!(elem, elem2);
} }
#[test] #[test]