Merge pull request #549 from winding-lines/coverage
test(error): increasing test coverage of error module
This commit is contained in:
25
src/error.rs
25
src/error.rs
@@ -129,7 +129,22 @@ mod tests {
|
||||
macro_rules! from {
|
||||
($from:expr => $error:pat) => {
|
||||
match Error::from($from) {
|
||||
$error => (),
|
||||
e @ $error => {
|
||||
assert!(e.description().len() > 5);
|
||||
} ,
|
||||
_ => panic!("{:?}", $from)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! from_and_cause {
|
||||
($from:expr => $error:pat) => {
|
||||
match Error::from($from) {
|
||||
e @ $error => {
|
||||
let desc = e.cause().unwrap().description();
|
||||
assert_eq!(desc, $from.description().to_owned());
|
||||
assert_eq!(desc, e.description());
|
||||
},
|
||||
_ => panic!("{:?}", $from)
|
||||
}
|
||||
}
|
||||
@@ -138,11 +153,11 @@ mod tests {
|
||||
#[test]
|
||||
fn test_from() {
|
||||
|
||||
from!(io::Error::new(io::ErrorKind::Other, "other") => Io(..));
|
||||
from!(url::ParseError::EmptyHost => Uri(..));
|
||||
from_and_cause!(io::Error::new(io::ErrorKind::Other, "other") => Io(..));
|
||||
from_and_cause!(url::ParseError::EmptyHost => Uri(..));
|
||||
from_and_cause!(SslError::SslSessionClosed => Ssl(..));
|
||||
|
||||
from!(SslError::StreamError(io::Error::new(io::ErrorKind::Other, "ssl")) => Io(..));
|
||||
from!(SslError::SslSessionClosed => Ssl(..));
|
||||
from!(SslError::StreamError(io::Error::new(io::ErrorKind::Other, "ssl negotiation")) => Io(..));
|
||||
|
||||
|
||||
from!(httparse::Error::HeaderName => Header);
|
||||
|
||||
Reference in New Issue
Block a user