Testing module

expect_near

procedure · 1 overloadsince 0.28.0Source

|got - want| <= tolerance. NaN is never near anything.

Example
expect_near(0.5, 0.25, 0.1);

This one is meant to fail, so there is nothing to run.

Example
expect_near("half", 0.5, 0.1);

This one is meant not to compile.

expect_near :: (
    got: float64,
    want: float64,
    tolerance: float64,
    loc := #caller_location
) -> bool

|got - want| <= tolerance. NaN is never near anything.

Parameters

got: float64
the value under test.
want: float64
the value it should be close to.
tolerance: float64
the largest allowed difference.
loc := #caller_location
where the check is written, shown when it fails. Leave the default.

Returns

bool
Example
expect_near(0.5, 0.25, 0.1);

This one is meant to fail, so there is nothing to run.

Example
expect_near("half", 0.5, 0.1);

This one is meant not to compile.

See also