More test cleanup

This commit is contained in:
Carl Lerche
2017-07-26 13:08:00 -07:00
parent 5dbeb0703b
commit 0f13836504
4 changed files with 414 additions and 409 deletions

View File

@@ -16,6 +16,7 @@ pub use self::futures::{
pub use self::http::{
request,
response,
method,
status,
};
@@ -24,6 +25,13 @@ pub use self::h2::{
server,
};
pub use self::bytes::{
Buf,
BufMut,
Bytes,
BytesMut,
};
pub trait MockH2 {
fn handshake(&mut self) -> &mut Self;
}
@@ -44,3 +52,27 @@ pub mod frames {
pub const SETTINGS: &'static [u8] = &[0, 0, 0, 4, 0, 0, 0, 0, 0];
pub const SETTINGS_ACK: &'static [u8] = &[0, 0, 0, 4, 1, 0, 0, 0, 0];
}
#[macro_export]
macro_rules! assert_user_err {
($actual:expr, $err:ident) => {{
use h2::error::{ConnectionError, User};
match $actual {
ConnectionError::User(e) => assert_eq!(e, User::$err),
_ => panic!("unexpected connection error type"),
}
}};
}
#[macro_export]
macro_rules! assert_proto_err {
($actual:expr, $err:ident) => {{
use h2::error::{ConnectionError, Reason};
match $actual {
ConnectionError::Proto(e) => assert_eq!(e, Reason::$err),
_ => panic!("unexpected connection error type"),
}
}};
}