macro_rules! assert_scalar_eq {
    ($x:expr, $y:expr) => { ... };
    ($x:expr, $y:expr, comp = exact) => { ... };
    ($x:expr, $y:expr, comp = abs, tol = $tol:expr) => { ... };
    ($x:expr, $y:expr, comp = ulp, tol = $tol:expr) => { ... };
    ($x:expr, $y:expr, comp = float) => { ... };
    ($x:expr, $y:expr, comp = float, $($key:ident = $val:expr),+) => { ... };
}
Expand description

Compare scalars for exact or approximate equality.

This macro works analogously to assert_matrix_eq!, but is used for comparing scalars (e.g. integers, floating-point numbers) rather than matrices. Please see the documentation for assert_matrix_eq! for details about issues that arise when comparing floating-point numbers, as well as an explanation for how these macros can be used to resolve these issues.

Examples

let x = 3.00;
let y = 3.05;
// Assert that |x - y| <= 0.1
assert_scalar_eq!(x, y, comp = abs, tol = 0.1);