macro_rules! assert_fn_gt_other_as_result {
($function:path, $a_input:expr, $b_input:expr $(,)?) => { ... };
}Expand description
Assert one function output is greater than another.
-
If true, return Result
Ok(()). -
Otherwise, return Result
Errwith a diagnostic message.
Examples
let a: i32 = -2;
let b: i32 = 1;
let x = assert_fn_gt_other_as_result!(i32::abs, a, b);
//-> Ok(())
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);
let a: i32 = 1;
let b: i32 = -2;
let x = assert_fn_gt_other_as_result!(i32::abs, a, b);
//-> Err(…)
let actual = x.unwrap_err();
let expect = concat!(
"assertion failed: `assert_fn_gt_other!(pair_function, left_input, right_input)`\n",
" pair_function label: `i32::abs`,\n",
" left_input label: `a`,\n",
" left_input debug: `1`,\n",
" right_input label: `b`,\n",
" right_input debug: `-2`,\n",
" left: `1`,\n",
" right: `2`"
);
assert_eq!(actual, expect);