From c45d1bf5ca5422686ef85a5b96c18cf312286550 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 1 Mar 2018 16:26:44 +0100 Subject: [PATCH] simplify tests for invalid JIDs --- src/lib.rs | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fb04453f..293c4a0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -421,31 +421,12 @@ mod tests { } #[test] - fn invalid() { - match Jid::from_str("") { - Err(JidParseError::NoDomain) => (), - err => panic!("Invalid error: {:?}", err) - } - - match Jid::from_str("a@/c") { - Err(JidParseError::NoDomain) => (), - err => panic!("Invalid error: {:?}", err) - } - - match Jid::from_str("/c") { - Err(JidParseError::NoDomain) => (), - err => panic!("Invalid error: {:?}", err) - } - - match Jid::from_str("@b") { - Err(JidParseError::EmptyNode) => (), - err => panic!("Invalid error: {:?}", err) - } - - match Jid::from_str("b/") { - Err(JidParseError::EmptyResource) => (), - err => panic!("Invalid error: {:?}", err) - } + fn invalid_jids() { + assert_eq!(Jid::from_str(""), Err(JidParseError::NoDomain)); + assert_eq!(Jid::from_str("/c"), Err(JidParseError::NoDomain)); + assert_eq!(Jid::from_str("a@/c"), Err(JidParseError::NoDomain)); + assert_eq!(Jid::from_str("@b"), Err(JidParseError::EmptyNode)); + assert_eq!(Jid::from_str("b/"), Err(JidParseError::EmptyResource)); } #[cfg(feature = "minidom")]