galvanic_assert::matchers

Function close_to

Source
pub fn close_to<'a, T>(expected: T, eps: T) -> Box<dyn Matcher<'a, T> + 'a>
where T: Copy + PartialOrd + Add<Output = T> + Sub<Output = T> + Debug + 'a,
Expand description

Matches if the asserted value is in an epsilon range around the expected value.

If floating point values are compared for equality this matcher should be used instead of equal_to

#Examples

use galvanic_assert::matchers::*;
assert_that!(&(1.2 + 3.14), close_to(4.34, 0.00001));