Fix warning: comparing floating point with == is unsafe

Use >= trick where value is guaranteed to never be greater than comparator
but to avoid warning: comparing floating point with == is unsafe.
This commit is contained in:
Mateusz Łoskot 2018-09-24 10:42:31 +02:00
parent 7a5bd6986e
commit afe0c2415b
No known key found for this signature in database
GPG Key ID: 928D7C2ABB2AC1F2

View File

@ -69,12 +69,17 @@ struct test_max_values
{
static inline void apply()
{
// Use >= where value is guaranteed to never be greater than comparator
// but to avoid warning: comparing floating point with == is unsafe.
Promoted min_value = (std::numeric_limits<Integral>::min)();
min_value *= min_value;
BOOST_CHECK(absolute_value<Promoted>::apply(min_value) == min_value);
BOOST_CHECK(absolute_value<Promoted>::apply(min_value) >= min_value);
BOOST_CHECK(absolute_value<Promoted>::apply(min_value) <= min_value);
Promoted max_value = (std::numeric_limits<Integral>::max)();
max_value *= max_value;
BOOST_CHECK(absolute_value<Promoted>::apply(max_value) == max_value);
BOOST_CHECK(absolute_value<Promoted>::apply(max_value) >= max_value);
BOOST_CHECK(absolute_value<Promoted>::apply(max_value) <= max_value);
#ifdef BOOST_GIL_TEST_DEBUG
std::cout << "integral min_value^2: " << min_value << std::endl;