mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +01:00
test: better assert_or_err messages
Co-authored-by: cschen <cschen@codemp.dev>
This commit is contained in:
parent
ee2ced51ca
commit
c42b091b63
1 changed files with 13 additions and 0 deletions
|
@ -48,6 +48,7 @@ impl From<RemoteError> for AssertionError {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! assert_or_err {
|
macro_rules! assert_or_err {
|
||||||
($s:expr) => {
|
($s:expr) => {
|
||||||
|
#[allow(clippy::bool_comparison)]
|
||||||
if !$s {
|
if !$s {
|
||||||
return Err($crate::tests::AssertionError::new(&format!(
|
return Err($crate::tests::AssertionError::new(&format!(
|
||||||
"assertion failed at line {}: {}",
|
"assertion failed at line {}: {}",
|
||||||
|
@ -58,6 +59,18 @@ macro_rules! assert_or_err {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($s:expr, $msg:literal) => {
|
($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 {
|
if !$s {
|
||||||
return Err($crate::tests::AssertionError::new($msg).into());
|
return Err($crate::tests::AssertionError::new($msg).into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue