Macro assertables::assert_f_err_string_ge
source · [−]macro_rules! assert_f_err_string_ge {
($function:path, $left:expr, $right:expr $(,)?) => { ... };
($function:path, $left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a function err() is greater than or equal to 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_err_string_ge!(example_digit_to_string, 20, 10);
//-> ()
assert_f_err_string_ge!(example_digit_to_string, 10, 20);
//-> panic!("…")
// assertion failed: `assert_f_err_string_ge!(function, left, right)`
// function: `\"example_digit_to_string\"`,
// left input: `10`,
// right input: `20`,
// left output: `\"10 is out of range\"`,
// right output: `\"20 is out of range\"This macro has a second form where a custom message can be provided.