Skip to main content

close_to

Function close_to 

Source
pub fn close_to<F>(value: F, tolerance: F) -> impl Matcher<F>
where F: Float,
Expand description

Matches a float within tolerance of value (the comparison is |actual - value| <= tolerance).

use test_better_core::TestResult;
use test_better_matchers::{close_to, check};

fn main() -> TestResult {
    check!(0.1_f64 + 0.2).satisfies(close_to(0.3, 1e-9))?;
    Ok(())
}