mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
message: Fix wrong parsing of the <body/> element, and add a test for it.
This commit is contained in:
parent
4278c8ce2b
commit
da31e72357
1 changed files with 6 additions and 2 deletions
|
@ -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]
|
||||||
|
|
Loading…
Reference in a new issue