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

Assert one function ok() is not equal to another function ok().

  • When true, return Ok(()).

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

Examples

fn f(i: i32) -> Result<bool, String> { Err(format!("{:?}", i)) }
let x = assertable_f_err_string_ne!(f, 1, 2);
//-> Ok(())
assert_eq!(x.unwrap(), ());

let x = assertable_f_err_string_ne!(f, 1, 1);
//-> Err("…")
// assertable failed: `assertable_f_err_string_ne!(function, left, right)`
//    left input: `1`,
//   right input: `1`,
//   left output: `\"1\"`,
//  right output: `\"1\"`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_f_err_string_ne!(function, left, right)`\n   left input: `1`,\n  right input: `1`,\n  left is err: `true`,\n right is err: `true`,\n  left output: `\"1\"`,\n right output: `\"1\"`".to_string());

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