Macro russell_chk::assert_approx_eq[][src]

macro_rules! assert_approx_eq {
    ($a : expr, $b : expr, $tol : expr) => { ... };
}
Expand description

Asserts that two numbers are approximately equal to each other, given a tolerance.

On panic, this macro will print the values of the expressions with their debug representations.

A tolerance must be given for the absolute comparison of float-point numbers.

Code based on assert_approx_eq

Examples

let a = 3.0000001;
let b = 3.0;
assert_approx_eq!(a, b, 1e-6);
let a = 1.0;
let b = 2.0;
assert_approx_eq!(a, b, 1e-6);