From 647dc998e483334cdbd8883aa655ea8e0e9014de Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 1 Sep 2014 05:57:03 -0700 Subject: [PATCH] unittests: correct some integers which should have been floating point types --- Source/UnitTests/Common/MathUtilTest.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/UnitTests/Common/MathUtilTest.cpp b/Source/UnitTests/Common/MathUtilTest.cpp index 3df22847be..8ae757962c 100644 --- a/Source/UnitTests/Common/MathUtilTest.cpp +++ b/Source/UnitTests/Common/MathUtilTest.cpp @@ -64,13 +64,15 @@ TEST(MathUtil, FlushToZero) // we want the multiplication to occur at test runtime. volatile float s = std::numeric_limits::denorm_min(); volatile double d = std::numeric_limits::denorm_min(); - EXPECT_LT(0, s * 2); - EXPECT_LT(0, d * 2); + // Casting away the volatile attribute is required in order for msvc to resolve this to the + // correct instance of the comparison function. + EXPECT_LT(0.f, (float)(s * 2)); + EXPECT_LT(0.0, (double)(d * 2)); - EXPECT_EQ(+0, MathUtil::FlushToZero(+std::numeric_limits::denorm_min())); - EXPECT_EQ(-0, MathUtil::FlushToZero(-std::numeric_limits::denorm_min())); - EXPECT_EQ(+0, MathUtil::FlushToZero(+std::numeric_limits::min() / 2)); - EXPECT_EQ(-0, MathUtil::FlushToZero(-std::numeric_limits::min() / 2)); + EXPECT_EQ(+0.0, MathUtil::FlushToZero(+std::numeric_limits::denorm_min())); + EXPECT_EQ(-0.0, MathUtil::FlushToZero(-std::numeric_limits::denorm_min())); + EXPECT_EQ(+0.0, MathUtil::FlushToZero(+std::numeric_limits::min() / 2)); + EXPECT_EQ(-0.0, MathUtil::FlushToZero(-std::numeric_limits::min() / 2)); EXPECT_EQ(std::numeric_limits::min(), MathUtil::FlushToZero(std::numeric_limits::min())); EXPECT_EQ(std::numeric_limits::max(), MathUtil::FlushToZero(std::numeric_limits::max())); EXPECT_EQ(+std::numeric_limits::infinity(), MathUtil::FlushToZero(+std::numeric_limits::infinity())); @@ -82,10 +84,10 @@ TEST(MathUtil, FlushToZero) for (u32 i = 0; i <= 0x007fffffu; ++i) { MathUtil::IntFloat x(i); - EXPECT_EQ(+0, MathUtil::FlushToZero(x.f)); + EXPECT_EQ(+0.f, MathUtil::FlushToZero(x.f)); x.i = i | 0x80000000u; - EXPECT_EQ(-0, MathUtil::FlushToZero(x.f)); + EXPECT_EQ(-0.f, MathUtil::FlushToZero(x.f)); x.i = dist(engine); MathUtil::IntFloat y(MathUtil::FlushToZero(x.f));