Skip to main content

assert_within

Function assert_within 

Source
pub fn assert_within(
    numerical: f64,
    reference: f64,
    tolerance: f64,
    label: &str,
)
Expand description

Asserts that numerical is within tolerance relative error of reference.

tolerance is interpreted on the same scale as relative_error (fractional, not percent). Panics with a descriptive message on failure.

§Panics

Panics if relative_error(numerical, reference) > tolerance.

§Examples

use solver::validation::assert_within;

assert_within(1.005, 1.0, 0.01, "trivial check");