aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2020-08-19 23:19:44 -0700
committerSiva Chandra Reddy <sivachandra@google.com>2020-08-20 08:31:31 -0700
commited8982da3e3122ffe2de8801d6ca1e1bd1e3c10a (patch)
treec18be4d65905264677a5e25b444a33091d44514e /libc/test
parente4e983e240430b3a0dc92402cc940292bd0d263f (diff)
downloadllvm-project-ed8982da3e3122ffe2de8801d6ca1e1bd1e3c10a.tar.gz
[libc][NFC] Switch math tests to the new ULP based tolerance.
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D86267
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/src/math/ceil_test.cpp6
-rw-r--r--libc/test/src/math/ceilf_test.cpp6
-rw-r--r--libc/test/src/math/ceill_test.cpp6
-rw-r--r--libc/test/src/math/cosf_test.cpp13
-rw-r--r--libc/test/src/math/exp2f_test.cpp24
-rw-r--r--libc/test/src/math/expf_test.cpp15
-rw-r--r--libc/test/src/math/fabs_test.cpp6
-rw-r--r--libc/test/src/math/fabsf_test.cpp7
-rw-r--r--libc/test/src/math/fabsl_test.cpp7
-rw-r--r--libc/test/src/math/floor_test.cpp6
-rw-r--r--libc/test/src/math/floorf_test.cpp6
-rw-r--r--libc/test/src/math/floorl_test.cpp6
-rw-r--r--libc/test/src/math/round_test.cpp6
-rw-r--r--libc/test/src/math/roundf_test.cpp6
-rw-r--r--libc/test/src/math/roundl_test.cpp6
-rw-r--r--libc/test/src/math/sincosf_test.cpp21
-rw-r--r--libc/test/src/math/sinf_test.cpp15
-rw-r--r--libc/test/src/math/trunc_test.cpp6
-rw-r--r--libc/test/src/math/truncf_test.cpp6
-rw-r--r--libc/test/src/math/truncl_test.cpp6
20 files changed, 46 insertions, 134 deletions
diff --git a/libc/test/src/math/ceil_test.cpp b/libc/test/src/math/ceil_test.cpp
index e012655638ab..bed06d8c53bb 100644
--- a/libc/test/src/math/ceil_test.cpp
+++ b/libc/test/src/math/ceil_test.cpp
@@ -23,9 +23,6 @@ static const double nan = FPBits::buildNaN(1);
static const double inf = FPBits::inf();
static const double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(CeilTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::ceil(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::ceil(negZero));
@@ -78,7 +75,6 @@ TEST(CeilTest, InDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceil(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceil(x), 0.0);
}
}
diff --git a/libc/test/src/math/ceilf_test.cpp b/libc/test/src/math/ceilf_test.cpp
index 2ad3770fcb9a..4efc07ddd736 100644
--- a/libc/test/src/math/ceilf_test.cpp
+++ b/libc/test/src/math/ceilf_test.cpp
@@ -23,9 +23,6 @@ static const float nan = FPBits::buildNaN(1);
static const float inf = FPBits::inf();
static const float negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(CeilfTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::ceilf(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::ceilf(negZero));
@@ -78,7 +75,6 @@ TEST(CeilfTest, InFloatRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceilf(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceilf(x), 0.0);
}
}
diff --git a/libc/test/src/math/ceill_test.cpp b/libc/test/src/math/ceill_test.cpp
index c1a385fff6ac..f6cb1819d9f4 100644
--- a/libc/test/src/math/ceill_test.cpp
+++ b/libc/test/src/math/ceill_test.cpp
@@ -23,9 +23,6 @@ static const long double nan = FPBits::buildNaN(1);
static const long double inf = FPBits::inf();
static const long double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(CeillTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::ceill(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::ceill(negZero));
@@ -78,7 +75,6 @@ TEST(CeillTest, InLongDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceill(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, __llvm_libc::ceill(x), 0.0);
}
}
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index ac6020e1a8f6..a8c5213676c1 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -32,11 +32,6 @@ using __llvm_libc::testing::sdcomp26094Values;
namespace mpfr = __llvm_libc::testing::mpfr;
-// 12 additional bits of precision over the base precision of a |float|
-// value.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 12,
- 3 * 0x1000 / 4};
-
TEST(CosfTest, SpecialNumbers) {
llvmlibc_errno = 0;
@@ -81,7 +76,7 @@ TEST(CosfTest, InFloatRange) {
float x = valueFromBits(v);
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), 1.0);
}
}
@@ -89,12 +84,12 @@ TEST(CosfTest, InFloatRange) {
TEST(CosfTest, SmallValues) {
float x = valueFromBits(0x17800000U);
float result = __llvm_libc::cosf(x);
- EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result, 1.0);
EXPECT_EQ(BitPatterns::one, valueAsBits(result));
x = valueFromBits(0x0040000U);
result = __llvm_libc::cosf(x);
- EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result, 1.0);
EXPECT_EQ(BitPatterns::one, valueAsBits(result));
}
@@ -103,6 +98,6 @@ TEST(CosfTest, SmallValues) {
TEST(CosfTest, SDCOMP_26094) {
for (uint32_t v : sdcomp26094Values) {
float x = valueFromBits(v);
- ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), 1.0);
}
}
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index fe9955f4cde4..1204de4770a0 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -28,11 +28,6 @@ using BitPatterns = __llvm_libc::fputil::BitPatterns<float>;
namespace mpfr = __llvm_libc::testing::mpfr;
-// 12 additional bits of precision over the base precision of a |float|
-// value.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 12,
- 0xFFF};
-
TEST(exp2fTest, SpecialNumbers) {
llvmlibc_errno = 0;
@@ -93,27 +88,27 @@ TEST(ExpfTest, Borderline) {
llvmlibc_errno = 0;
x = valueFromBits(0x42fa0001U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0x42ffffffU);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc2fa0001U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc2fc0000U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc2fc0001U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc3150000U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
}
@@ -125,12 +120,12 @@ TEST(ExpfTest, Underflow) {
llvmlibc_errno = 0;
float x = valueFromBits(0xc3158000U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, ERANGE);
llvmlibc_errno = 0;
x = valueFromBits(0xc3165432U);
- EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
EXPECT_EQ(llvmlibc_errno, ERANGE);
}
@@ -150,7 +145,6 @@ TEST(exp2fTest, InFloatRange) {
// wider precision.
if (isnan(result) || isinf(result) || llvmlibc_errno != 0)
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 1.0);
}
}
diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp
index 577f5e40d82b..e7951a308278 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -28,11 +28,6 @@ using BitPatterns = __llvm_libc::fputil::BitPatterns<float>;
namespace mpfr = __llvm_libc::testing::mpfr;
-// 12 additional bits of precision over the base precision of a |float|
-// value.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 12,
- 0xFFF};
-
TEST(ExpfTest, SpecialNumbers) {
llvmlibc_errno = 0;
@@ -110,19 +105,19 @@ TEST(ExpfTest, Borderline) {
llvmlibc_errno = 0;
x = valueFromBits(0x42affff8U);
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0x42b00008U);
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc2affff8U);
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
x = valueFromBits(0xc2b00008U);
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 1.0);
EXPECT_EQ(llvmlibc_errno, 0);
}
@@ -142,6 +137,6 @@ TEST(ExpfTest, InFloatRange) {
// wider precision.
if (isnan(result) || isinf(result) || llvmlibc_errno != 0)
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 1.0);
}
}
diff --git a/libc/test/src/math/fabs_test.cpp b/libc/test/src/math/fabs_test.cpp
index 4c3f28f06d30..277ed604d7e8 100644
--- a/libc/test/src/math/fabs_test.cpp
+++ b/libc/test/src/math/fabs_test.cpp
@@ -23,10 +23,6 @@ static const double negInf = FPBits::negInf();
namespace mpfr = __llvm_libc::testing::mpfr;
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::doublePrecision, 0,
- 0};
-
TEST(FabsTest, SpecialNumbers) {
EXPECT_FP_EQ(nan, __llvm_libc::fabs(nan));
@@ -45,6 +41,6 @@ TEST(FabsTest, InDoubleRange) {
double x = FPBits(v);
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabs(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabs(x), 0.0);
}
}
diff --git a/libc/test/src/math/fabsf_test.cpp b/libc/test/src/math/fabsf_test.cpp
index 83425d7d2f8f..2a735510acce 100644
--- a/libc/test/src/math/fabsf_test.cpp
+++ b/libc/test/src/math/fabsf_test.cpp
@@ -23,10 +23,6 @@ static const float negInf = FPBits::negInf();
namespace mpfr = __llvm_libc::testing::mpfr;
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
-
TEST(FabsfTest, SpecialNumbers) {
EXPECT_FP_EQ(nan, __llvm_libc::fabsf(nan));
@@ -45,7 +41,6 @@ TEST(FabsfTest, InFloatRange) {
float x = FPBits(v);
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabsf(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabsf(x), 0.0);
}
}
diff --git a/libc/test/src/math/fabsl_test.cpp b/libc/test/src/math/fabsl_test.cpp
index b2ceb0c6205c..86f1275d4dfe 100644
--- a/libc/test/src/math/fabsl_test.cpp
+++ b/libc/test/src/math/fabsl_test.cpp
@@ -23,10 +23,6 @@ static const long double negInf = FPBits::negInf();
namespace mpfr = __llvm_libc::testing::mpfr;
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
-
TEST(FabslTest, SpecialNumbers) {
EXPECT_FP_EQ(nan, __llvm_libc::fabsl(nan));
@@ -45,7 +41,6 @@ TEST(FabslTest, InLongDoubleRange) {
long double x = FPBits(v);
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabsl(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, __llvm_libc::fabsl(x), 0.0);
}
}
diff --git a/libc/test/src/math/floor_test.cpp b/libc/test/src/math/floor_test.cpp
index 34b9bec11858..5f59c3c14c96 100644
--- a/libc/test/src/math/floor_test.cpp
+++ b/libc/test/src/math/floor_test.cpp
@@ -23,9 +23,6 @@ static const double nan = FPBits::buildNaN(1);
static const double inf = FPBits::inf();
static const double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(FloorTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::floor(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::floor(negZero));
@@ -78,7 +75,6 @@ TEST(FloorTest, InDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floor(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floor(x), 0.0);
}
}
diff --git a/libc/test/src/math/floorf_test.cpp b/libc/test/src/math/floorf_test.cpp
index 0eb6b1f3bda3..08c34638d125 100644
--- a/libc/test/src/math/floorf_test.cpp
+++ b/libc/test/src/math/floorf_test.cpp
@@ -23,9 +23,6 @@ static const float nan = FPBits::buildNaN(1);
static const float inf = FPBits::inf();
static const float negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(FloorfTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::floorf(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::floorf(negZero));
@@ -78,7 +75,6 @@ TEST(FloorfTest, InFloatRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floorf(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floorf(x), 0.0);
}
}
diff --git a/libc/test/src/math/floorl_test.cpp b/libc/test/src/math/floorl_test.cpp
index 3ed2435f3f48..c6aea659635c 100644
--- a/libc/test/src/math/floorl_test.cpp
+++ b/libc/test/src/math/floorl_test.cpp
@@ -23,9 +23,6 @@ static const long double nan = FPBits::buildNaN(1);
static const long double inf = FPBits::inf();
static const long double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(FloorlTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::floorl(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::floorl(negZero));
@@ -78,7 +75,6 @@ TEST(FloorlTest, InLongDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floorl(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, __llvm_libc::floorl(x), 0.0);
}
}
diff --git a/libc/test/src/math/round_test.cpp b/libc/test/src/math/round_test.cpp
index 0cfaead1dc3b..0ff1fde3c2f3 100644
--- a/libc/test/src/math/round_test.cpp
+++ b/libc/test/src/math/round_test.cpp
@@ -23,9 +23,6 @@ static const double nan = FPBits::buildNaN(1);
static const double inf = FPBits::inf();
static const double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(RoundTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::round(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::round(negZero));
@@ -78,7 +75,6 @@ TEST(RoundTest, InDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::round(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::round(x), 0.0);
}
}
diff --git a/libc/test/src/math/roundf_test.cpp b/libc/test/src/math/roundf_test.cpp
index 6771b3fd2288..6ddd122d7e6f 100644
--- a/libc/test/src/math/roundf_test.cpp
+++ b/libc/test/src/math/roundf_test.cpp
@@ -23,9 +23,6 @@ static const float nan = FPBits::buildNaN(1);
static const float inf = FPBits::inf();
static const float negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(RoundfTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::roundf(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::roundf(negZero));
@@ -78,7 +75,6 @@ TEST(RoundfTest, InFloatRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::roundf(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::roundf(x), 0.0);
}
}
diff --git a/libc/test/src/math/roundl_test.cpp b/libc/test/src/math/roundl_test.cpp
index ff5d799319f4..e032f5145af4 100644
--- a/libc/test/src/math/roundl_test.cpp
+++ b/libc/test/src/math/roundl_test.cpp
@@ -23,9 +23,6 @@ static const long double nan = FPBits::buildNaN(1);
static const long double inf = FPBits::inf();
static const long double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(RoundlTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::roundl(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::roundl(negZero));
@@ -78,7 +75,6 @@ TEST(RoundlTest, InLongDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::roundl(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, __llvm_libc::roundl(x), 0.0);
}
}
diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 2211ef1dc6e2..9e5ee062cc8d 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -32,11 +32,6 @@ using __llvm_libc::testing::sdcomp26094Values;
namespace mpfr = __llvm_libc::testing::mpfr;
-// 12 additional bits of precision over the base precision of a |float|
-// value.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 12,
- 3 * 0x1000 / 4};
-
TEST(SinCosfTest, SpecialNumbers) {
llvmlibc_errno = 0;
float sin, cos;
@@ -96,8 +91,8 @@ TEST(SinCosfTest, InFloatRange) {
float sin, cos;
__llvm_libc::sincosf(x, &sin, &cos);
- ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, cos, tolerance);
- ASSERT_MPFR_MATCH(mpfr::Operation::Sin, x, sin, tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, cos, 1.0);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Sin, x, sin, 1.0);
}
}
@@ -107,16 +102,16 @@ TEST(SinCosfTest, SmallValues) {
float x = valueFromBits(bits);
float result_cos, result_sin;
__llvm_libc::sincosf(x, &result_sin, &result_cos);
- EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result_cos, tolerance);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result_sin, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result_cos, 1.0);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result_sin, 1.0);
EXPECT_EQ(BitPatterns::one, valueAsBits(result_cos));
EXPECT_EQ(bits, valueAsBits(result_sin));
bits = 0x00400000;
x = valueFromBits(bits);
__llvm_libc::sincosf(x, &result_sin, &result_cos);
- EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result_cos, tolerance);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result_sin, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, result_cos, 1.0);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result_sin, 1.0);
EXPECT_EQ(BitPatterns::one, valueAsBits(result_cos));
EXPECT_EQ(bits, valueAsBits(result_sin));
}
@@ -128,7 +123,7 @@ TEST(SinCosfTest, SDCOMP_26094) {
float x = valueFromBits(v);
float sin, cos;
__llvm_libc::sincosf(x, &sin, &cos);
- EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, cos, tolerance);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, sin, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, cos, 1.0);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, sin, 1.0);
}
}
diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 17c66712fd02..67dca0072deb 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -32,11 +32,6 @@ using __llvm_libc::testing::sdcomp26094Values;
namespace mpfr = __llvm_libc::testing::mpfr;
-// 12 additional bits of precision over the base precision of a |float|
-// value.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 12,
- 3 * 0x1000 / 4};
-
TEST(SinfTest, SpecialNumbers) {
llvmlibc_errno = 0;
@@ -81,13 +76,13 @@ TEST(SinfTest, InFloatRange) {
float x = valueFromBits(v);
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 1.0);
}
}
TEST(SinfTest, SpecificBitPatterns) {
float x = valueFromBits(0xc70d39a1);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 1.0);
}
// For small values, sin(x) is x.
@@ -95,13 +90,13 @@ TEST(SinfTest, SmallValues) {
uint32_t bits = 0x17800000;
float x = valueFromBits(bits);
float result = __llvm_libc::sinf(x);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result, 1.0);
EXPECT_EQ(bits, valueAsBits(result));
bits = 0x00400000;
x = valueFromBits(bits);
result = __llvm_libc::sinf(x);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result, tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, result, 1.0);
EXPECT_EQ(bits, valueAsBits(result));
}
@@ -110,6 +105,6 @@ TEST(SinfTest, SmallValues) {
TEST(SinfTest, SDCOMP_26094) {
for (uint32_t v : sdcomp26094Values) {
float x = valueFromBits(v);
- EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), tolerance);
+ EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 1.0);
}
}
diff --git a/libc/test/src/math/trunc_test.cpp b/libc/test/src/math/trunc_test.cpp
index 855492ab4cb8..806f02cb2a22 100644
--- a/libc/test/src/math/trunc_test.cpp
+++ b/libc/test/src/math/trunc_test.cpp
@@ -23,9 +23,6 @@ static const double nan = FPBits::buildNaN(1);
static const double inf = FPBits::inf();
static const double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(TruncTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::trunc(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::trunc(negZero));
@@ -78,7 +75,6 @@ TEST(TruncTest, InDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::trunc(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::trunc(x), 0.0);
}
}
diff --git a/libc/test/src/math/truncf_test.cpp b/libc/test/src/math/truncf_test.cpp
index a87cb14b1503..99cb487c4a29 100644
--- a/libc/test/src/math/truncf_test.cpp
+++ b/libc/test/src/math/truncf_test.cpp
@@ -23,9 +23,6 @@ static const float nan = FPBits::buildNaN(1);
static const float inf = FPBits::inf();
static const float negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(TruncfTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::truncf(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::truncf(negZero));
@@ -78,7 +75,6 @@ TEST(TruncfTest, InFloatRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::truncf(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::truncf(x), 0.0);
}
}
diff --git a/libc/test/src/math/truncl_test.cpp b/libc/test/src/math/truncl_test.cpp
index 2ea6fe58a63d..8f7668db5275 100644
--- a/libc/test/src/math/truncl_test.cpp
+++ b/libc/test/src/math/truncl_test.cpp
@@ -23,9 +23,6 @@ static const long double nan = FPBits::buildNaN(1);
static const long double inf = FPBits::inf();
static const long double negInf = FPBits::negInf();
-// Zero tolerance; As in, exact match with MPFR result.
-static constexpr mpfr::Tolerance tolerance{mpfr::Tolerance::floatPrecision, 0,
- 0};
TEST(TrunclTest, SpecialNumbers) {
EXPECT_FP_EQ(zero, __llvm_libc::truncl(zero));
EXPECT_FP_EQ(negZero, __llvm_libc::truncl(negZero));
@@ -78,7 +75,6 @@ TEST(TrunclTest, InLongDoubleRange) {
if (isnan(x) || isinf(x))
continue;
- ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::truncl(x),
- tolerance);
+ ASSERT_MPFR_MATCH(mpfr::Operation::Trunc, x, __llvm_libc::truncl(x), 0.0);
}
}