From afe0c2415bfa80ad77dad6d74beb0e3f9dfaea99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Mon, 24 Sep 2018 10:42:31 +0200 Subject: [PATCH] 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. --- test/promote_integral.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/promote_integral.cpp b/test/promote_integral.cpp index ddee3977b..4178ef812 100644 --- a/test/promote_integral.cpp +++ b/test/promote_integral.cpp @@ -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::min)(); min_value *= min_value; - BOOST_CHECK(absolute_value::apply(min_value) == min_value); + BOOST_CHECK(absolute_value::apply(min_value) >= min_value); + BOOST_CHECK(absolute_value::apply(min_value) <= min_value); Promoted max_value = (std::numeric_limits::max)(); max_value *= max_value; - BOOST_CHECK(absolute_value::apply(max_value) == max_value); + BOOST_CHECK(absolute_value::apply(max_value) >= max_value); + BOOST_CHECK(absolute_value::apply(max_value) <= max_value); #ifdef BOOST_GIL_TEST_DEBUG std::cout << "integral min_value^2: " << min_value << std::endl;