mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
use unreachable instead of panic
This commit is contained in:
parent
3e98177fad
commit
145010a2b0
@ -766,7 +766,7 @@ mod tests {
|
||||
e @ $error => {
|
||||
assert!(format!("{}", e).len() >= 5);
|
||||
} ,
|
||||
e => panic!("{:?}", e)
|
||||
e => unreachable!("{:?}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -778,7 +778,7 @@ mod tests {
|
||||
let desc = format!("{}", e.cause().unwrap());
|
||||
assert_eq!(desc, $from.description().to_owned());
|
||||
},
|
||||
_ => panic!("{:?}", $from)
|
||||
_ => unreachable!("{:?}", $from)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,27 +581,27 @@ mod tests {
|
||||
let req = TestRequest::with_header(header::CONTENT_LENGTH, "xxxx").finish();
|
||||
match req.body().poll().err().unwrap() {
|
||||
PayloadError::UnknownLength => (),
|
||||
_ => panic!("error"),
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
|
||||
let req = TestRequest::with_header(header::CONTENT_LENGTH, "1000000").finish();
|
||||
match req.body().poll().err().unwrap() {
|
||||
PayloadError::Overflow => (),
|
||||
_ => panic!("error"),
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
|
||||
let mut req = HttpRequest::default();
|
||||
req.payload_mut().unread_data(Bytes::from_static(b"test"));
|
||||
match req.body().poll().ok().unwrap() {
|
||||
Async::Ready(bytes) => assert_eq!(bytes, Bytes::from_static(b"test")),
|
||||
_ => panic!("error"),
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
|
||||
let mut req = HttpRequest::default();
|
||||
req.payload_mut().unread_data(Bytes::from_static(b"11111111111111"));
|
||||
match req.body().limit(5).poll().err().unwrap() {
|
||||
PayloadError::Overflow => (),
|
||||
_ => panic!("error"),
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ mod tests {
|
||||
let headers = HeaderMap::new();
|
||||
match Multipart::boundary(&headers) {
|
||||
Err(MultipartError::NoContentType) => (),
|
||||
_ => panic!("should not happen"),
|
||||
_ => unreachable!("should not happen"),
|
||||
}
|
||||
|
||||
let mut headers = HeaderMap::new();
|
||||
@ -641,7 +641,7 @@ mod tests {
|
||||
|
||||
match Multipart::boundary(&headers) {
|
||||
Err(MultipartError::ParseContentType) => (),
|
||||
_ => panic!("should not happen"),
|
||||
_ => unreachable!("should not happen"),
|
||||
}
|
||||
|
||||
let mut headers = HeaderMap::new();
|
||||
@ -650,7 +650,7 @@ mod tests {
|
||||
header::HeaderValue::from_static("multipart/mixed"));
|
||||
match Multipart::boundary(&headers) {
|
||||
Err(MultipartError::Boundary) => (),
|
||||
_ => panic!("should not happen"),
|
||||
_ => unreachable!("should not happen"),
|
||||
}
|
||||
|
||||
let mut headers = HeaderMap::new();
|
||||
|
@ -932,8 +932,8 @@ mod tests {
|
||||
macro_rules! not_ready {
|
||||
($e:expr) => (match $e {
|
||||
Ok(Async::NotReady) => (),
|
||||
Err(err) => panic!("Unexpected error: {:?}", err),
|
||||
_ => panic!("Should not be ready"),
|
||||
Err(err) => unreachable!("Unexpected error: {:?}", err),
|
||||
_ => unreachable!("Should not be ready"),
|
||||
})
|
||||
}
|
||||
|
||||
@ -943,8 +943,8 @@ mod tests {
|
||||
Vec::new(), KeepAlive::Os);
|
||||
match Reader::new().parse($e, &mut BytesMut::new(), &settings) {
|
||||
Ok(Async::Ready(req)) => req,
|
||||
Ok(_) => panic!("Eof during parsing http request"),
|
||||
Err(err) => panic!("Error during parsing http request: {:?}", err),
|
||||
Ok(_) => unreachable!("Eof during parsing http request"),
|
||||
Err(err) => unreachable!("Error during parsing http request: {:?}", err),
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -953,8 +953,8 @@ mod tests {
|
||||
($e:expr) => (
|
||||
match $e {
|
||||
Ok(Async::Ready(req)) => req,
|
||||
Ok(_) => panic!("Eof during parsing http request"),
|
||||
Err(err) => panic!("Error during parsing http request: {:?}", err),
|
||||
Ok(_) => unreachable!("Eof during parsing http request"),
|
||||
Err(err) => unreachable!("Error during parsing http request: {:?}", err),
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -968,10 +968,10 @@ mod tests {
|
||||
match Reader::new().parse($e, &mut buf, &settings) {
|
||||
Err(err) => match err {
|
||||
ReaderError::Error(_) => (),
|
||||
_ => panic!("Parse error expected"),
|
||||
_ => unreachable!("Parse error expected"),
|
||||
},
|
||||
_ => {
|
||||
panic!("Error expected")
|
||||
unreachable!("Error expected")
|
||||
}
|
||||
}}
|
||||
)
|
||||
@ -991,7 +991,7 @@ mod tests {
|
||||
assert_eq!(*req.method(), Method::GET);
|
||||
assert_eq!(req.path(), "/test");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,7 +1005,7 @@ mod tests {
|
||||
let mut reader = Reader::new();
|
||||
match reader.parse(&mut buf, &mut readbuf, &settings) {
|
||||
Ok(Async::NotReady) => (),
|
||||
_ => panic!("Error"),
|
||||
_ => unreachable!("Error"),
|
||||
}
|
||||
|
||||
buf.feed_data(".1\r\n\r\n");
|
||||
@ -1015,7 +1015,7 @@ mod tests {
|
||||
assert_eq!(*req.method(), Method::PUT);
|
||||
assert_eq!(req.path(), "/test");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1033,7 +1033,7 @@ mod tests {
|
||||
assert_eq!(*req.method(), Method::POST);
|
||||
assert_eq!(req.path(), "/test2");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,7 +1052,7 @@ mod tests {
|
||||
assert_eq!(req.path(), "/test");
|
||||
assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ mod tests {
|
||||
assert_eq!(req.path(), "/test");
|
||||
assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1093,7 +1093,7 @@ mod tests {
|
||||
assert_eq!(*req.method(), Method::GET);
|
||||
assert_eq!(req.path(), "/test");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1121,7 +1121,7 @@ mod tests {
|
||||
assert_eq!(req.path(), "/test");
|
||||
assert_eq!(req.headers().get("test").unwrap().as_bytes(), b"value");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1143,7 +1143,7 @@ mod tests {
|
||||
assert_eq!(val[0], "c1=cookie1");
|
||||
assert_eq!(val[1], "c2=cookie2");
|
||||
}
|
||||
Ok(_) | Err(_) => panic!("Error during parsing http request"),
|
||||
Ok(_) | Err(_) => unreachable!("Error during parsing http request"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1256,7 +1256,7 @@ mod tests {
|
||||
if let Ok(val) = req.chunked() {
|
||||
assert!(val);
|
||||
} else {
|
||||
panic!("Error");
|
||||
unreachable!("Error");
|
||||
}
|
||||
|
||||
// type in chunked
|
||||
@ -1268,7 +1268,7 @@ mod tests {
|
||||
if let Ok(val) = req.chunked() {
|
||||
assert!(!val);
|
||||
} else {
|
||||
panic!("Error");
|
||||
unreachable!("Error");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,7 +1501,7 @@ mod tests {
|
||||
let mut reader = Reader::new();
|
||||
match reader.parse(&mut buf) {
|
||||
Ok(res) => (),
|
||||
Err(err) => panic!("{:?}", err),
|
||||
Err(err) => unreachable!("{:?}", err),
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ mod tests {
|
||||
fn extract(frm: Poll<Option<Frame>, ProtocolError>) -> Frame {
|
||||
match frm {
|
||||
Ok(Async::Ready(Some(frame))) => frame,
|
||||
_ => panic!("error"),
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ mod tests {
|
||||
|
||||
if let Err(ProtocolError::Overflow) = Frame::parse(&mut buf, false, 0) {
|
||||
} else {
|
||||
panic!("error");
|
||||
unreachable!("error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ mod test {
|
||||
($from:expr => $opcode:pat) => {
|
||||
match OpCode::from($from) {
|
||||
e @ $opcode => (),
|
||||
e => panic!("{:?}", e)
|
||||
e => unreachable!("{:?}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ mod test {
|
||||
let res: u8 = $from.into();
|
||||
match res {
|
||||
e @ $opcode => (),
|
||||
e => panic!("{:?}", e)
|
||||
e => unreachable!("{:?}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user