test: better assert_or_err messages

Co-authored-by: cschen <cschen@codemp.dev>
This commit is contained in:
əlemi 2024-11-05 00:16:27 +01:00
parent ee2ced51ca
commit c42b091b63
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -48,6 +48,7 @@ impl From<RemoteError> for AssertionError {
#[macro_export]
macro_rules! assert_or_err {
($s:expr) => {
#[allow(clippy::bool_comparison)]
if !$s {
return Err($crate::tests::AssertionError::new(&format!(
"assertion failed at line {}: {}",
@ -58,6 +59,18 @@ macro_rules! assert_or_err {
}
};
($s:expr, $msg:literal) => {
#[allow(clippy::bool_comparison)]
if !$s {
return Err($crate::tests::AssertionError::new(&format!(
"{} (line {})",
$msg,
std::line!(),
))
.into());
}
};
($s:expr, raw $msg:literal) => {
#[allow(clippy::bool_comparison)]
if !$s {
return Err($crate::tests::AssertionError::new($msg).into());
}