Macro assertables::assert_f_ok_lt
source · [−]macro_rules! assert_f_ok_lt {
($function:path, $left:expr, $right:expr $(,)?) => { ... };
($function:path, $left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a function ok() is less than another.
-
When true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
Examples
fn example_digit_to_string(i: isize) -> Result<String, String> {
match i {
0..=9 => Ok(format!("{}", i)),
_ => Err(format!("{:?} is out of range", i)),
}
}
assert_f_ok_lt!(example_digit_to_string, 1, 2);
//-> ()
assert_f_ok_lt!(example_digit_to_string, 2, 1);
//-> panic!
// assertion failed: `assert_f_ok_lt!(function, left, right)`
// function: `\"example_digit_to_string\"`,
// left input: `2`,
// right input: `1`,
// left output: `\"2\"`,
// right output: `\"1\"`This macro has a second form where a custom message can be provided.