From da31e7235718ee7eaf1f9fcb276e9b3ae78bd369 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 7 May 2017 15:06:11 +0100 Subject: [PATCH] message: Fix wrong parsing of the element, and add a test for it. --- src/message.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/message.rs b/src/message.rs index 2c8959b..3248451 100644 --- a/src/message.rs +++ b/src/message.rs @@ -166,7 +166,7 @@ impl<'a> TryFrom<&'a Element> for Message { to: to, id: id, type_: type_, - bodies: BTreeMap::new(), + bodies: bodies, subjects: subjects, payloads: payloads, }) @@ -263,7 +263,11 @@ mod tests { #[test] fn test_body() { let elem: Element = "Hello world!".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]