diff options
author | Siva Chandra Reddy <sivachandra@google.com> | 2020-10-31 22:28:44 -0700 |
---|---|---|
committer | Siva Chandra Reddy <sivachandra@google.com> | 2020-11-03 15:44:06 -0800 |
commit | 50c2f2b6f0ccb5bb72896dc14ed8e8c89fa7a0c7 (patch) | |
tree | 348f2b142590055c941f8ff7970150804548358b /libc/test | |
parent | 0fca6517118d435f9c2d7afe6135fd5f357509b5 (diff) | |
download | llvm-project-50c2f2b6f0ccb5bb72896dc14ed8e8c89fa7a0c7.tar.gz |
[libc][NFC][Obvious] Use the new macro to declare special constants in tests.
Diffstat (limited to 'libc/test')
28 files changed, 31 insertions, 125 deletions
diff --git a/libc/test/src/math/ceil_test.cpp b/libc/test/src/math/ceil_test.cpp index bed06d8c53bb..c42bdb99d45b 100644 --- a/libc/test/src/math/ceil_test.cpp +++ b/libc/test/src/math/ceil_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; 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(CeilTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::ceil(zero)); diff --git a/libc/test/src/math/ceilf_test.cpp b/libc/test/src/math/ceilf_test.cpp index 4efc07ddd736..bfd4d5239998 100644 --- a/libc/test/src/math/ceilf_test.cpp +++ b/libc/test/src/math/ceilf_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; 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(CeilfTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::ceilf(zero)); diff --git a/libc/test/src/math/ceill_test.cpp b/libc/test/src/math/ceill_test.cpp index f6cb1819d9f4..ce0cc472eac2 100644 --- a/libc/test/src/math/ceill_test.cpp +++ b/libc/test/src/math/ceill_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; 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(CeillTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::ceill(zero)); diff --git a/libc/test/src/math/copysign_test.cpp b/libc/test/src/math/copysign_test.cpp index 676e8fed95d4..2bcadbcb7571 100644 --- a/libc/test/src/math/copysign_test.cpp +++ b/libc/test/src/math/copysign_test.cpp @@ -14,11 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; -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(CopySignTest, SpecialNumbers) { EXPECT_FP_EQ(nan, __llvm_libc::copysign(nan, -1.0)); diff --git a/libc/test/src/math/copysignf_test.cpp b/libc/test/src/math/copysignf_test.cpp index a7c434635545..4f98c5682f2a 100644 --- a/libc/test/src/math/copysignf_test.cpp +++ b/libc/test/src/math/copysignf_test.cpp @@ -14,11 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; -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(CopySinfTest, SpecialNumbers) { EXPECT_FP_EQ(nan, __llvm_libc::copysignf(nan, -1.0)); diff --git a/libc/test/src/math/copysignl_test.cpp b/libc/test/src/math/copysignl_test.cpp index efe54e4eca6b..e84bc8ddbec6 100644 --- a/libc/test/src/math/copysignl_test.cpp +++ b/libc/test/src/math/copysignl_test.cpp @@ -14,11 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; -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(CopySinlTest, SpecialNumbers) { EXPECT_FP_EQ(nan, __llvm_libc::copysignl(nan, -1.0)); diff --git a/libc/test/src/math/fabs_test.cpp b/libc/test/src/math/fabs_test.cpp index 277ed604d7e8..1dff39b07801 100644 --- a/libc/test/src/math/fabs_test.cpp +++ b/libc/test/src/math/fabs_test.cpp @@ -15,11 +15,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; -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) namespace mpfr = __llvm_libc::testing::mpfr; diff --git a/libc/test/src/math/fabsf_test.cpp b/libc/test/src/math/fabsf_test.cpp index 2a735510acce..2243e263a552 100644 --- a/libc/test/src/math/fabsf_test.cpp +++ b/libc/test/src/math/fabsf_test.cpp @@ -15,11 +15,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; -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) namespace mpfr = __llvm_libc::testing::mpfr; diff --git a/libc/test/src/math/fabsl_test.cpp b/libc/test/src/math/fabsl_test.cpp index 86f1275d4dfe..51edd4cea0b7 100644 --- a/libc/test/src/math/fabsl_test.cpp +++ b/libc/test/src/math/fabsl_test.cpp @@ -15,11 +15,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; -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) namespace mpfr = __llvm_libc::testing::mpfr; diff --git a/libc/test/src/math/floor_test.cpp b/libc/test/src/math/floor_test.cpp index 5f59c3c14c96..d0e26541d111 100644 --- a/libc/test/src/math/floor_test.cpp +++ b/libc/test/src/math/floor_test.cpp @@ -15,13 +15,9 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; -namespace mpfr = __llvm_libc::testing::mpfr; +DECLARE_SPECIAL_CONSTANTS(double) -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(); +namespace mpfr = __llvm_libc::testing::mpfr; TEST(FloorTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::floor(zero)); diff --git a/libc/test/src/math/floorf_test.cpp b/libc/test/src/math/floorf_test.cpp index 08c34638d125..8de4ab24fd9f 100644 --- a/libc/test/src/math/floorf_test.cpp +++ b/libc/test/src/math/floorf_test.cpp @@ -15,13 +15,9 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; -namespace mpfr = __llvm_libc::testing::mpfr; +DECLARE_SPECIAL_CONSTANTS(float) -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(); +namespace mpfr = __llvm_libc::testing::mpfr; TEST(FloorfTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::floorf(zero)); diff --git a/libc/test/src/math/floorl_test.cpp b/libc/test/src/math/floorl_test.cpp index c6aea659635c..9f70cadc25db 100644 --- a/libc/test/src/math/floorl_test.cpp +++ b/libc/test/src/math/floorl_test.cpp @@ -15,13 +15,9 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; -namespace mpfr = __llvm_libc::testing::mpfr; +DECLARE_SPECIAL_CONSTANTS(long double) -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(); +namespace mpfr = __llvm_libc::testing::mpfr; TEST(FloorlTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::floorl(zero)); diff --git a/libc/test/src/math/fmax_test.cpp b/libc/test/src/math/fmax_test.cpp index 0dc57e4290fc..5579bb67e7dd 100644 --- a/libc/test/src/math/fmax_test.cpp +++ b/libc/test/src/math/fmax_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; -double nan = FPBits::buildNaN(1); -double inf = FPBits::inf(); -double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(double) TEST(FmaxTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fmax(nan, inf)); diff --git a/libc/test/src/math/fmaxf_test.cpp b/libc/test/src/math/fmaxf_test.cpp index fc8f1cc2512c..d4d92bf2a30d 100644 --- a/libc/test/src/math/fmaxf_test.cpp +++ b/libc/test/src/math/fmaxf_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; -float nan = FPBits::buildNaN(1); -float inf = FPBits::inf(); -float negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(float) TEST(FmaxfTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fmaxf(nan, inf)); diff --git a/libc/test/src/math/fmaxl_test.cpp b/libc/test/src/math/fmaxl_test.cpp index ac62899d1a96..be9b0c830b14 100644 --- a/libc/test/src/math/fmaxl_test.cpp +++ b/libc/test/src/math/fmaxl_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; -long double nan = FPBits::buildNaN(1); -long double inf = FPBits::inf(); -long double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(long double) TEST(FmaxlTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fmaxl(nan, inf)); diff --git a/libc/test/src/math/fmin_test.cpp b/libc/test/src/math/fmin_test.cpp index 47a4433f0c95..67d75506b1fc 100644 --- a/libc/test/src/math/fmin_test.cpp +++ b/libc/test/src/math/fmin_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; -double nan = static_cast<double>(FPBits::buildNaN(1)); -double inf = static_cast<double>(FPBits::inf()); -double negInf = static_cast<double>(FPBits::negInf()); +DECLARE_SPECIAL_CONSTANTS(double) TEST(FminTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fmin(nan, inf)); diff --git a/libc/test/src/math/fminf_test.cpp b/libc/test/src/math/fminf_test.cpp index 20bcdb950291..a40bf021c9b0 100644 --- a/libc/test/src/math/fminf_test.cpp +++ b/libc/test/src/math/fminf_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; -float nan = static_cast<float>(FPBits::buildNaN(1)); -float inf = static_cast<float>(FPBits::inf()); -float negInf = static_cast<float>(FPBits::negInf()); +DECLARE_SPECIAL_CONSTANTS(float) TEST(FminfTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fminf(nan, inf)); diff --git a/libc/test/src/math/fminl_test.cpp b/libc/test/src/math/fminl_test.cpp index ea770bc07e4f..274ef296ce41 100644 --- a/libc/test/src/math/fminl_test.cpp +++ b/libc/test/src/math/fminl_test.cpp @@ -14,9 +14,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; -long double nan = static_cast<long double>(FPBits::buildNaN(1)); -long double inf = static_cast<long double>(FPBits::inf()); -long double negInf = static_cast<long double>(FPBits::negInf()); +DECLARE_SPECIAL_CONSTANTS(long double) TEST(FminlTest, NaNArg) { EXPECT_FP_EQ(inf, __llvm_libc::fminl(nan, inf)); diff --git a/libc/test/src/math/hypotf_test.cpp b/libc/test/src/math/hypotf_test.cpp index 7b1ffd5241db..eb06c799fee3 100644 --- a/libc/test/src/math/hypotf_test.cpp +++ b/libc/test/src/math/hypotf_test.cpp @@ -18,11 +18,7 @@ using UIntType = FPBits::UIntType; 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(HypotfTest, SpecialNumbers) { EXPECT_FP_EQ(__llvm_libc::hypotf(inf, nan), inf); diff --git a/libc/test/src/math/round_test.cpp b/libc/test/src/math/round_test.cpp index 0ff1fde3c2f3..8d9114544383 100644 --- a/libc/test/src/math/round_test.cpp +++ b/libc/test/src/math/round_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; 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(RoundTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::round(zero)); diff --git a/libc/test/src/math/roundf_test.cpp b/libc/test/src/math/roundf_test.cpp index 6ddd122d7e6f..93252da9efe3 100644 --- a/libc/test/src/math/roundf_test.cpp +++ b/libc/test/src/math/roundf_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; 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(RoundfTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::roundf(zero)); diff --git a/libc/test/src/math/roundl_test.cpp b/libc/test/src/math/roundl_test.cpp index e032f5145af4..424dd78a0ab5 100644 --- a/libc/test/src/math/roundl_test.cpp +++ b/libc/test/src/math/roundl_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; 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(RoundlTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::roundl(zero)); diff --git a/libc/test/src/math/sqrt_test.cpp b/libc/test/src/math/sqrt_test.cpp index 7ff4978ec9e3..1fda63e16908 100644 --- a/libc/test/src/math/sqrt_test.cpp +++ b/libc/test/src/math/sqrt_test.cpp @@ -20,9 +20,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; constexpr UIntType HiddenBit = UIntType(1) << __llvm_libc::fputil::MantissaWidth<double>::value; -double nan = FPBits::buildNaN(1); -double inf = FPBits::inf(); -double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(double) TEST(SqrtTest, SpecialValues) { ASSERT_FP_EQ(nan, __llvm_libc::sqrt(nan)); diff --git a/libc/test/src/math/sqrtf_test.cpp b/libc/test/src/math/sqrtf_test.cpp index 8c429065bb45..1e9eda048bf7 100644 --- a/libc/test/src/math/sqrtf_test.cpp +++ b/libc/test/src/math/sqrtf_test.cpp @@ -20,9 +20,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; constexpr UIntType HiddenBit = UIntType(1) << __llvm_libc::fputil::MantissaWidth<float>::value; -float nan = FPBits::buildNaN(1); -float inf = FPBits::inf(); -float negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(float) TEST(SqrtfTest, SpecialValues) { ASSERT_FP_EQ(nan, __llvm_libc::sqrtf(nan)); diff --git a/libc/test/src/math/sqrtl_test.cpp b/libc/test/src/math/sqrtl_test.cpp index 1fab3b2567e5..36b3030355ba 100644 --- a/libc/test/src/math/sqrtl_test.cpp +++ b/libc/test/src/math/sqrtl_test.cpp @@ -20,9 +20,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; constexpr UIntType HiddenBit = UIntType(1) << __llvm_libc::fputil::MantissaWidth<long double>::value; -long double nan = FPBits::buildNaN(1); -long double inf = FPBits::inf(); -long double negInf = FPBits::negInf(); +DECLARE_SPECIAL_CONSTANTS(long double) TEST(SqrtlTest, SpecialValues) { ASSERT_FP_EQ(nan, __llvm_libc::sqrtl(nan)); diff --git a/libc/test/src/math/trunc_test.cpp b/libc/test/src/math/trunc_test.cpp index 806f02cb2a22..0a322facab39 100644 --- a/libc/test/src/math/trunc_test.cpp +++ b/libc/test/src/math/trunc_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<double>; 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(TruncTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::trunc(zero)); diff --git a/libc/test/src/math/truncf_test.cpp b/libc/test/src/math/truncf_test.cpp index 99cb487c4a29..0732614f7440 100644 --- a/libc/test/src/math/truncf_test.cpp +++ b/libc/test/src/math/truncf_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<float>; 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(TruncfTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::truncf(zero)); diff --git a/libc/test/src/math/truncl_test.cpp b/libc/test/src/math/truncl_test.cpp index 8f7668db5275..ab05d01905c4 100644 --- a/libc/test/src/math/truncl_test.cpp +++ b/libc/test/src/math/truncl_test.cpp @@ -17,11 +17,7 @@ using FPBits = __llvm_libc::fputil::FPBits<long double>; 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(TrunclTest, SpecialNumbers) { EXPECT_FP_EQ(zero, __llvm_libc::truncl(zero)); |