[][src]Macro gramit::assert_within_threshold

macro_rules! assert_within_threshold {
    ($a:expr, $b:expr, $thresh:expr, $($msg:expr),*) => { ... };
    ($a:expr, $b:expr, $thresh:expr) => { ... };
}

Assert that two expressions are within a threshold specified by the third parameter, according to their ApproxEq implementations.

Passes additional parameters on to the standard library assert! macro, so custom format messages are accepted as per usual.

Example

use gramit::ApproxEq;
assert_within_threshold!(1.0, 1.5, 0.75);
assert_within_threshold!(0.0, 0.1, 0.2,
    "{} and {} were not within distance {} from each other; this shouldn't happen!",
    0.0, 0.1, 0.2);
use gramit::ApproxEq;
// Panics!
assert_within_threshold!(1.0, 2.0, 0.5);