10 #define BOOST_TEST_MODULE ( RealComparisons_test )
11 #include <boost/test/unit_test.hpp>
26 double const sqrt2 = std::sqrt(2);
29 double const epsilon = 2.0 - (sqrt2 * sqrt2);
30 BOOST_TEST( check.
zero(epsilon));
31 BOOST_TEST( check.
zero(0.0));
32 BOOST_TEST( check.
zero(1
e-5));
33 BOOST_TEST( check.
zero(-1
e-5));
34 BOOST_TEST(!check.
zero(1.01e-5));
35 BOOST_TEST(!check.
zero(-1.01e-5 * 1.01));
38 BOOST_TEST(!check.
nonZero(epsilon));
39 BOOST_TEST(!check.
nonZero(0.0));
42 BOOST_TEST( check.
nonZero(1.01e-5));
43 BOOST_TEST( check.
nonZero(-1.01e-5 * 1.01));
46 BOOST_TEST(!check.
equal(sqrt2, 1.4142));
47 BOOST_TEST( check.
nonEqual(sqrt2, 1.4142));
48 BOOST_TEST( check.
equal(sqrt2, 1.414213));
49 BOOST_TEST(!check.
nonEqual(sqrt2, 1.414213));
108 BOOST_TEST(!check.
within(sqrt2, 0., 1.41420));
109 BOOST_TEST( check.
within(sqrt2, 0., 1.41421));
110 BOOST_TEST( check.
within(sqrt2, 1.41422, 2.));
111 BOOST_TEST(!check.
within(sqrt2, 1.41423, 2.));
114 BOOST_TEST(!check.
within(sqrt2, 1.41421, 0.));
constexpr bool nonEqual(Value_t a, Value_t b) const
Returns whether a and b are farther than the threshold.
Provides simple real number checks.
constexpr bool zero(Value_t value) const
Returns whether the value is no farther from 0 than the threshold.
Class for approximate comparisons.
constexpr bool withinSorted(Value_t value, Value_t lower, Value_t upper) const
Returns whether value is between bounds (included); bounds are sorted.
constexpr bool strictlySmaller(Value_t a, Value_t b) const
Returns whether a is strictly smaller than b.
constexpr bool strictlyGreater(Value_t a, Value_t b) const
Returns whether a is strictly greater than b.
process_name tightIsolTest check
constexpr bool strictlyNegative(Value_t value) const
Returns whether value is larger than zero beyond tolerance.
constexpr bool nonGreater(Value_t a, Value_t b) const
Returns whether a is smaller than (or equal to) b.
constexpr bool strictlyPositive(Value_t value) const
Returns whether value is smaller than zero beyond tolerance.
constexpr bool nonNegative(Value_t value) const
Returns whether value is larger than or equal() to zero.
constexpr bool nonZero(Value_t value) const
Returns whether the value is farther from 0 than the threshold.
constexpr bool nonSmaller(Value_t a, Value_t b) const
Returns whether a is greater than (or equal to) b.
constexpr bool equal(Value_t a, Value_t b) const
Returns whether a and b are no farther than the threshold.
constexpr bool nonPositive(Value_t value) const
Returns whether value is smaller than or equal() to zero.
constexpr bool within(Value_t value, Value_t lower, Value_t upper) const
Returns whether value is between the bounds (included)