From bb8aa2ad1ae7050b82a76e38affd1294772b213b Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Sat, 17 Apr 2021 05:41:20 +0000 Subject: [PATCH] [libc][NFC] Use explicit conversion in modfl_test. --- libc/test/src/math/modfl_test.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/libc/test/src/math/modfl_test.cpp b/libc/test/src/math/modfl_test.cpp index e8f292a..fae4690 100644 --- a/libc/test/src/math/modfl_test.cpp +++ b/libc/test/src/math/modfl_test.cpp @@ -13,48 +13,52 @@ #include "utils/UnitTest/Test.h" #include +typedef long double LD; using FPBits = __llvm_libc::fputil::FPBits; TEST(LlvmLibcmodflTest, SpecialNumbers) { long double integral; - EXPECT_TRUE(FPBits::zero() == __llvm_libc::modfl(FPBits::inf(), &integral)); - EXPECT_TRUE(FPBits::inf() == integral); + EXPECT_TRUE(LD(FPBits::zero()) == + __llvm_libc::modfl(LD(FPBits::inf()), &integral)); + EXPECT_TRUE(LD(FPBits::inf()) == integral); - EXPECT_TRUE(FPBits::negZero() == - __llvm_libc::modfl(FPBits::negInf(), &integral)); - EXPECT_TRUE(FPBits::negInf() == integral); + EXPECT_TRUE(LD(FPBits::negZero()) == + __llvm_libc::modfl(LD(FPBits::negInf()), &integral)); + EXPECT_TRUE(LD(FPBits::negInf()) == integral); - EXPECT_TRUE(FPBits::zero() == __llvm_libc::modfl(FPBits::zero(), &integral)); + EXPECT_TRUE(LD(FPBits::zero()) == + __llvm_libc::modfl(LD(FPBits::zero()), &integral)); EXPECT_TRUE(integral == 0.0l); - EXPECT_TRUE(FPBits::negZero() == - __llvm_libc::modfl(FPBits::negZero(), &integral)); + EXPECT_TRUE(LD(FPBits::negZero()) == + __llvm_libc::modfl(LD(FPBits::negZero()), &integral)); EXPECT_TRUE(integral == 0.0l); EXPECT_TRUE( - FPBits(__llvm_libc::modfl(FPBits::buildNaN(1), &integral)).isNaN()); + FPBits(__llvm_libc::modfl(LD(FPBits::buildNaN(1)), &integral)).isNaN()); } TEST(LlvmLibcmodflTest, Integers) { long double integral; - EXPECT_TRUE(FPBits::zero() == __llvm_libc::modfl(1.0l, &integral)); + EXPECT_TRUE(LD(FPBits::zero()) == __llvm_libc::modfl(1.0l, &integral)); EXPECT_TRUE(integral == 1.0l); - EXPECT_TRUE(FPBits::negZero() == __llvm_libc::modfl(-1.0l, &integral)); + EXPECT_TRUE(LD(FPBits::negZero()) == __llvm_libc::modfl(-1.0l, &integral)); EXPECT_TRUE(integral == -1.0l); - EXPECT_TRUE(FPBits::zero() == __llvm_libc::modfl(10.0l, &integral)); + EXPECT_TRUE(LD(FPBits::zero()) == __llvm_libc::modfl(10.0l, &integral)); EXPECT_TRUE(integral == 10.0l); - EXPECT_TRUE(FPBits::negZero() == __llvm_libc::modfl(-10.0l, &integral)); + EXPECT_TRUE(LD(FPBits::negZero()) == __llvm_libc::modfl(-10.0l, &integral)); EXPECT_TRUE(integral == -10.0l); - EXPECT_TRUE(FPBits::zero() == __llvm_libc::modfl(12345.0l, &integral)); + EXPECT_TRUE(LD(FPBits::zero()) == __llvm_libc::modfl(12345.0l, &integral)); EXPECT_TRUE(integral == 12345.0l); - EXPECT_TRUE(FPBits::negZero() == __llvm_libc::modfl(-12345.0l, &integral)); + EXPECT_TRUE(LD(FPBits::negZero()) == + __llvm_libc::modfl(-12345.0l, &integral)); EXPECT_TRUE(integral == -12345.0l); } @@ -85,7 +89,7 @@ TEST(LlvmLibcModflTest, LongDoubleRange) { constexpr UIntType count = 10000000; constexpr UIntType step = UIntType(-1) / count; for (UIntType i = 0, v = 0; i <= count; ++i, v += step) { - long double x = FPBits(v); + long double x = LD(FPBits(v)); if (isnan(x) || isinf(x) || x == 0.0l) continue; -- 2.7.4