assert_fn_eq

Macro assert_fn_eq 

Source
macro_rules! assert_fn_eq {
    ($a_function:path, $a_param:expr, $b_function:path, $b_param:expr $(,)?) => { ... };
    ($a_function:path, $a_param:expr, $b_function:path, $b_param:expr, $($message:tt)+) => { ... };
    ($a_function:path, $b_function:path) => { ... };
    ($a_function:path, $b_function:path, $($message:tt)+) => { ... };
}
Expand description

Assert a function output is equal to another.

Pseudocode:
a_function(a) == b_function(b)

  • If true, return (a, b).

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use assertables::*;

let a: i8 = -1;
let b: i8 = 1;
assert_fn_eq!(i8::abs, a, i8::abs, b);

// This will panic
let a: i8 = -1;
let b: i8 = 2;
assert_fn_eq!(i8::abs, a, i8::abs, b);
// assertion failed: `assert_fn_eq!(a_function, a_param, b_function, b_param)`
// https://docs.rs/assertables/…/assertables/macro.assert_fn_eq.html
//  a_function label: `i8::abs`,
//     a_param label: `a`,
//     a_param debug: `-1`,
//  b_function label: `i8::abs`,
//     b_param label: `b`,
//     b_param debug: `2`,
//                 a: `1`,
//                 b: `2`

§Module macros