Macro assert_eq_float::assert_ne_float
source · macro_rules! assert_ne_float { (@standard $left:ident, $right:ident, $error:ident) => { ... }; (@custom $left:ident, $right:ident, $error:ident; $($arg:tt)+) => { ... }; ($left:expr, $right:expr $(,)?) => { ... }; ($left:expr, $right:expr; $($arg:tt)+) => { ... }; ($left:expr, $right:expr, $error:expr $(,)?) => { ... }; ($left:expr, $right:expr, $error:expr; $($arg:tt)+) => { ... }; }
Expand description
Asserts that two float expressions are not (approximately) equal to each other.
On panic, this macro will print the values of the expressions with their debug representations.
Like assert_ne!
, this macro has a second form, where a custom
panic message can be provided.
§Examples
use assert_eq_float::assert_ne_float;
let a = 3.01;
let b = 1.0 + 2.0;
assert_ne_float!(a, b);
assert_ne_float!(a, b; "we are testing addition with {} and {}", a, b);
assert_ne_float!(a, b, 1e-7); // use a fixed error
Note that when setting a custom panic message, you should use a semicolon ;
instead of a comma ,
.