Assertions in the Unit Test Framework use two kinds
of comparison. For
being close to zero with absolute tolerance
abs(u) <= eps; // (abs)
v being close with relative tolerance
abs(u - v)/abs(u) <= eps && abs(u - v)/abs(v) <= eps; // (rel)
For rationale for choosing these formulae, see section Floating point comparison algorithms.
BOOST_TEST (when comparing floating-point
numbers) uses the following algorithm:
vis zero, evaluates formula (abs) on the other value.
Therefore in order to check if a number is close to zero with tolerance, you need to type:
BOOST_TEST(v == T(0), tt::tolerance(eps));
The compatibility assertion
BOOST_<level>_SMALL performs formula (abs).
Tolerance-based computations also apply to
operator< and other relational operators. The
semantics are defined as follows:
This implies that the exactly one of these:
Relation less-at-tolerance is not a Strict Weak Ordering; using it
as predicate in