From e5575ba8056bff8d96e6c7698d4cd44beda51eb3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 18 Nov 2016 14:57:16 +0000 Subject: [PATCH] Fix cast issue in poor_quality_tests The comparison in the if statement and the test didn't match, which I think is why this test was sometimes failling. But should still try to write something that will work for floats. --- hash/test/hash_number_test.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 9adb5c6..ebfe4d4 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -127,9 +127,13 @@ void poor_quality_tests(T*) BOOST_TEST(x1(T(1)) != x2(T(-1))); if(T(1) != T(2)) BOOST_TEST(x1(T(1)) != x2(T(2))); - if((limits::max)() != (limits::max)() - 1) - BOOST_TEST(x1(static_cast((limits::max)())) - != x2(static_cast((limits::max)() - 1))); + + // TODO: This test is useless for floating point numbers. + T max_number = static_cast((limits::max)()); + T max_minus_one = static_cast(max_number - 1); + if (max_number != max_minus_one) { + BOOST_TEST(x1(max_number) != x1(max_minus_one)); + } } void bool_test()