From c42b091b63ed6f76a953178cc5f87887d8990827 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 5 Nov 2024 00:16:27 +0100 Subject: [PATCH] test: better assert_or_err messages Co-authored-by: cschen --- src/tests/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tests/mod.rs b/src/tests/mod.rs index b699b4f..802c364 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -48,6 +48,7 @@ impl From 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()); }