add tests for some XML errors

This commit is contained in:
Emmanuel Gil Peyrot 2018-02-18 19:41:03 +01:00
parent 74fb62f953
commit 055caa8e24

View file

@ -197,3 +197,24 @@ fn namespace_inherited_prefixed2() {
assert_eq!(child.name(), "message");
assert_eq!(child.ns(), Some("jabber:client".to_owned()));
}
#[test]
fn xml_error() {
match "<a></b>".parse::<Element>() {
Err(::error::Error(::error::ErrorKind::XmlError(_), _)) => (),
err => panic!("No or wrong error: {:?}", err)
}
match "<a></".parse::<Element>() {
Err(::error::Error(::error::ErrorKind::XmlError(_), _)) => (),
err => panic!("No or wrong error: {:?}", err)
}
}
#[test]
fn invalid_element_error() {
match "<a:b:c>".parse::<Element>() {
Err(::error::Error(::error::ErrorKind::InvalidElement, _)) => (),
err => panic!("No or wrong error: {:?}", err)
}
}