0.1.0[][src]Macro appro_eq::assert_appro_eq_rel

macro_rules! assert_appro_eq_rel {
    ($a:expr, $b:expr) => { ... };
    ($a:expr, $b:expr, $eps:expr) => { ... };
}

Asserts that the relative error of the two expressions is small enough.

You can optionally add an optional diff value. If you don't supply a diff value as an argument, Tolerance::tolerance() is the default used.

Examples

assert_appro_eq_rel!(1f64, 1.5f64, 0.6f64); // does not panic
assert_appro_eq_rel!(1f64, 1.0 + 1e-12f64); // does not panic
assert_appro_eq_rel!(vec![1f64, 1.0, 1.0], vec![1.0 + 1e-12f64, 1.0, 1.0 - 1e-13f64]); // does not panic
This example panics
assert_appro_eq_rel!(1f64, 2f64); // panics