Skip to content

Commit 1e5d7d4

Browse files
committed
Merge pull request #549 from winding-lines/coverage
test(error): increasing test coverage of error module
2 parents 0953b26 + b24e1a5 commit 1e5d7d4

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/error.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,22 @@ mod tests {
129129
macro_rules! from {
130130
($from:expr => $error:pat) => {
131131
match Error::from($from) {
132-
$error => (),
132+
e @ $error => {
133+
assert!(e.description().len() > 5);
134+
} ,
135+
_ => panic!("{:?}", $from)
136+
}
137+
}
138+
}
139+
140+
macro_rules! from_and_cause {
141+
($from:expr => $error:pat) => {
142+
match Error::from($from) {
143+
e @ $error => {
144+
let desc = e.cause().unwrap().description();
145+
assert_eq!(desc, $from.description().to_owned());
146+
assert_eq!(desc, e.description());
147+
},
133148
_ => panic!("{:?}", $from)
134149
}
135150
}
@@ -138,11 +153,11 @@ mod tests {
138153
#[test]
139154
fn test_from() {
140155

141-
from!(io::Error::new(io::ErrorKind::Other, "other") => Io(..));
142-
from!(url::ParseError::EmptyHost => Uri(..));
156+
from_and_cause!(io::Error::new(io::ErrorKind::Other, "other") => Io(..));
157+
from_and_cause!(url::ParseError::EmptyHost => Uri(..));
158+
from_and_cause!(SslError::SslSessionClosed => Ssl(..));
143159

144-
from!(SslError::StreamError(io::Error::new(io::ErrorKind::Other, "ssl")) => Io(..));
145-
from!(SslError::SslSessionClosed => Ssl(..));
160+
from!(SslError::StreamError(io::Error::new(io::ErrorKind::Other, "ssl negotiation")) => Io(..));
146161

147162

148163
from!(httparse::Error::HeaderName => Header);

0 commit comments

Comments
 (0)