diff --git a/src/jingle.rs b/src/jingle.rs index e732c6b430b57a8331cae6c6863784da477f3ff6..37912a020c6a02edd9e54d14e85a5f4fdb722189 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use minidom::Element; use error::Error; -use ns::{JINGLE_NS}; +use ns::JINGLE_NS; #[derive(Debug, PartialEq)] pub enum Action { @@ -285,6 +285,9 @@ pub fn parse_jingle(root: &Element) -> Result { } let name = stuff.name(); if name == "text" { + if text.is_some() { + return Err(Error::ParseError("Reason must not have more than one text.")); + } text = Some(stuff.text()); } else { reason = Some(name.parse()?); @@ -487,5 +490,13 @@ mod tests { _ => panic!(), }; assert_eq!(message, "Jingle must not have more than one reason."); + + let elem: Element = "".parse().unwrap(); + let error = jingle::parse_jingle(&elem).unwrap_err(); + let message = match error { + Error::ParseError(string) => string, + _ => panic!(), + }; + assert_eq!(message, "Reason must not have more than one text."); } }