diff --git a/libc/test/src/math/remquo_test.cpp b/libc/test/src/math/remquo_test.cpp --- a/libc/test/src/math/remquo_test.cpp +++ b/libc/test/src/math/remquo_test.cpp @@ -19,11 +19,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; -static const double zero = FPBits::zero(); -static const double negZero = FPBits::negZero(); -static const double nan = FPBits::buildNaN(1); -static const double inf = FPBits::inf(); -static const double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(double) TEST(RemquoTest, SpecialNumbers) { int exponent; diff --git a/libc/test/src/math/remquof_test.cpp b/libc/test/src/math/remquof_test.cpp --- a/libc/test/src/math/remquof_test.cpp +++ b/libc/test/src/math/remquof_test.cpp @@ -19,11 +19,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; -static const float zero = FPBits::zero(); -static const float negZero = FPBits::negZero(); -static const float nan = FPBits::buildNaN(1); -static const float inf = FPBits::inf(); -static const float negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(float) TEST(RemquofTest, SpecialNumbers) { int exponent; diff --git a/libc/test/src/math/remquol_test.cpp b/libc/test/src/math/remquol_test.cpp --- a/libc/test/src/math/remquol_test.cpp +++ b/libc/test/src/math/remquol_test.cpp @@ -19,13 +19,9 @@ namespace mpfr = __llvm_libc::testing::mpfr; -static const long double zero = FPBits::zero(); -static const long double negZero = FPBits::negZero(); -static const long double nan = FPBits::buildNaN(1); -static const long double inf = FPBits::inf(); -static const long double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(long double) -TEST(RemquoTest, SpecialNumbers) { +TEST(RemquolTest, SpecialNumbers) { int exponent; long double x, y; @@ -62,7 +58,7 @@ EXPECT_FP_EQ(__llvm_libc::remquol(x, y, &exponent), negZero); } -TEST(RemquofTest, SubnormalRange) { +TEST(RemquolTest, SubnormalRange) { constexpr UIntType count = 1000001; constexpr UIntType step = (FPBits::maxSubnormal - FPBits::minSubnormal) / count; @@ -77,7 +73,7 @@ } } -TEST(RemquofTest, NormalRange) { +TEST(RemquolTest, NormalRange) { constexpr UIntType count = 1000001; constexpr UIntType step = (FPBits::maxNormal - FPBits::minNormal) / count; for (UIntType v = FPBits::minNormal, w = FPBits::maxNormal; diff --git a/libc/utils/FPUtil/TestHelpers.h b/libc/utils/FPUtil/TestHelpers.h --- a/libc/utils/FPUtil/TestHelpers.h +++ b/libc/utils/FPUtil/TestHelpers.h @@ -65,6 +65,13 @@ } // namespace fputil } // namespace __llvm_libc +#define DECLARE_SPECIAL_CONSTANTS(T) \ + static const T zero = __llvm_libc::fputil::FPBits::zero(); \ + static const T negZero = __llvm_libc::fputil::FPBits::negZero(); \ + static const T nan = __llvm_libc::fputil::FPBits::buildNaN(1); \ + static const T inf = __llvm_libc::fputil::FPBits::inf(); \ + static const T negInf = __llvm_libc::fputil::FPBits::negInf(); + #define EXPECT_FP_EQ(expected, actual) \ EXPECT_THAT( \ actual, \