macro_rules! assert_fn_err_gt { ($a_function:path, $a_param:expr, $b_function:path, $b_param:expr $(,)?) => { ... }; ($a_function:path, $a_param:expr, $b_function:path, $b_param:expr, $($message:tt)+) => { ... }; ($a_function:path, $b_function:path) => { ... }; ($a_function:path, $b_function:path, $($message:tt)+) => { ... }; }
Expand description
Assert a function error is greater than another.
Pseudocode:
(function1(param1) ⇒ Err(a) ⇒ a) > (function2(param2) ⇒ Err(b) ⇒ b)
-
If true, return
()
. -
Otherwise, call
panic!
with a message and the values of the expressions with their debug representations.
§Examples
fn f(i: i8) -> Result<String, String> {
match i {
0..=9 => Ok(format!("{}", i)),
_ => Err(format!("{:?} is out of range", i)),
}
}
let a: i8 = 20;
let b: i8 = 10;
assert_fn_err_gt!(f, a, f, b);
let a: i8 = 10;
let b: i8 = 20;
assert_fn_err_gt!(f, a, f, b);
// assertion failed: `assert_fn_err_gt!(a_function, a_param, b_function, b_param)`
// https://docs.rs/assertables/8.9.0/assertables/macro.assert_fn_err_gt.html
// a_function label: `f`,
// a_param label: `a`,
// a_param debug: `10`,
// b_function label: `f`,
// b_param label: `b`,
// b_param debug: `20`,
// a: `\"10 is out of range\"`,
// b: `\"20 is out of range\"`