#[macro_export]
macro_rules! expect {
($cond:expr $(,)?) => {
if !$cond {
$crate::disappoint(
Box::new(concat!("expectation disappointed: ", stringify!($cond))),
file!(),
line!(),
column!(),
);
}
};
($cond:expr, $($arg:tt)+) => {
if !$cond {
$crate::disappoint(
Box::new(format!($($arg)+)),
file!(),
line!(),
column!(),
);
}
};
}
#[macro_export]
macro_rules! expect_eq {
($lhs:expr, $rhs:expr $(,)?) => {
match (&$lhs, &$rhs) {
(lhs, rhs) => {
if !(*lhs == *rhs) {
$crate::disappoint(
Box::new(format!(
r#"expectation disappointed: `(left == right)`
left: `{:?}`,
right: `{:?}`"#,
&*lhs, &*rhs
)),
file!(),
line!(),
column!(),
);
}
}
}
};
($lhs:expr, $rhs:expr, $($arg:tt)+) => {
match (&$lhs, &$rhs) {
(lhs, rhs) => {
if !(*lhs == *rhs) {
$crate::disappoint(
Box::new(format!(
r#"expectation disappointed: `(left == right)`
left: `{:?}`,
right: `{:?}`: {}"#,
&*lhs, &*rhs, format_args!($($arg)+)
)),
file!(),
line!(),
column!(),
);
}
}
}
};
}