shouldApproxEqual

Verify that two floating point values are approximately equal

void
shouldApproxEqual
(
V
E
)
(
in V value
,,
double maxRelDiff = 1e-2
,
double maxAbsDiff = 1e-5
,
string file = __FILE__
,
size_t line = __LINE__
)
if (
(
isFloatingPoint!V ||
isFloatingPoint!E
)
&&
is(typeof(value == expected) == bool)
)

Parameters

value V

the value to check.

expected E

the expected value

maxRelDiff double

the maximum relative difference

maxAbsDiff double

the maximum absolute difference

Throws

UnitTestException on failure

Examples

1.0.shouldApproxEqual(1.0001);

Meta