macro_rules! assertable_f_ok_gt {
    ($function:path, $left:expr, $right:expr $(,)?) => { ... };
    ($function:path, $left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert one function ok() is greater than anoter.

  • When true, return Ok(()).

  • Otherwise, return Err with a message and the values of the expressions with their debug representations.

Examples

use std::str::FromStr;
let x = assertable_f_ok_gt!(i32::from_str, "2", "1");
//-> Ok(())
assert_eq!(x.unwrap(), ());

let x = assertable_f_ok_gt!(i32::from_str, "1", "2");
//-> Err("…")
// assertable failed: `assertable_f_ok_gt!(function, left, right)`
//    left input: `\"1\"`,
//   right input: `\"2\"`,
//   left output: `1`,
//  right output: `2`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_f_ok_gt!(function, left, right)`\n   left input: `\"1\"`,\n  right input: `\"2\"`,\n  left output: `1`,\n right output: `2`".to_string());

This macro has a second form where a custom message can be provided.