2017-07-13 07:37:15 +00:00
|
|
|
macro_rules! not_err {
|
2018-07-18 05:26:33 +00:00
|
|
|
($e:expr) => {
|
|
|
|
match $e {
|
|
|
|
Ok(e) => e,
|
|
|
|
Err(e) => panic!("{} failed with {:?}", stringify!($e), e),
|
|
|
|
}
|
|
|
|
};
|
2017-07-13 07:37:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! is_err {
|
2018-07-18 05:26:33 +00:00
|
|
|
($e:expr) => {
|
|
|
|
match $e {
|
|
|
|
Ok(e) => panic!(
|
|
|
|
"{} did not return with an error, but with {:?}",
|
|
|
|
stringify!($e),
|
|
|
|
e
|
|
|
|
),
|
|
|
|
Err(e) => e,
|
|
|
|
}
|
|
|
|
};
|
2017-07-13 07:37:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! assert_matches {
|
2018-07-18 05:26:33 +00:00
|
|
|
($e:expr, $p:pat) => {
|
|
|
|
assert_matches!($e, $p, ())
|
|
|
|
};
|
|
|
|
($e:expr, $p:pat, $f:expr) => {
|
|
|
|
match $e {
|
|
|
|
$p => $f,
|
|
|
|
e => panic!(
|
2017-07-13 07:37:15 +00:00
|
|
|
"{}: Expected pattern {} \ndoes not match {:?}",
|
2018-07-18 05:26:33 +00:00
|
|
|
stringify!($e),
|
|
|
|
stringify!($p),
|
|
|
|
e
|
|
|
|
),
|
2017-07-13 07:37:15 +00:00
|
|
|
}
|
2018-07-18 05:26:33 +00:00
|
|
|
};
|
2017-07-13 07:37:15 +00:00
|
|
|
}
|