Macro assertables::assertable_f_ok_lt
source · [−]macro_rules! assertable_f_ok_lt {
($function:path, $left:expr, $right:expr $(,)?) => { ... };
($function:path, $left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Assert one function ok() is less than anoter.
-
When true, return
Ok(()). -
Otherwise, return
Errwith a message and the values of the expressions with their debug representations.
Examples
use std::str::FromStr;
let x = assertable_f_ok_lt!(i32::from_str, "1", "2");
//-> Ok(())
assert_eq!(x.unwrap(), ());
let x = assertable_f_ok_lt!(i32::from_str, "2", "1");
//-> Err("…")
// assertable failed: `assertable_f_ok_lt!(function, left, right)`
// left input: `\"2\"`,
// right input: `\"1\"`,
// left output: `2`,
// right output: `1`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_f_ok_lt!(function, left, right)`\n left input: `\"2\"`,\n right input: `\"1\"`,\n left output: `2`,\n right output: `1`".to_string());This macro has a second form where a custom message can be provided.