aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/math/log1p_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/src/math/log1p_test.cpp')
-rw-r--r--libc/test/src/math/log1p_test.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index be83ce8..dd72073 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -7,13 +7,19 @@
//===----------------------------------------------------------------------===//
#include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
#include "src/math/log1p.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
using LlvmLibcLog1pTest = LIBC_NAMESPACE::testing::FPTest<double>;
@@ -68,7 +74,7 @@ TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
for (int i = 0; i < N; ++i) {
double x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
- LIBC_NAMESPACE::log1p(x), 0.5);
+ LIBC_NAMESPACE::log1p(x), TOLERANCE + 0.5);
}
}
@@ -107,9 +113,8 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) {
continue;
++count;
- // ASSERT_MPFR_MATCH(mpfr::Operation::Log1p, x, result, 0.5);
if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x, result,
- 0.5, rounding_mode)) {
+ TOLERANCE + 0.5, rounding_mode)) {
++fails;
while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x,
result, tol, rounding_mode)) {
@@ -119,10 +124,10 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) {
}
}
}
- tlog << " Log1p failed: " << fails << "/" << count << "/" << cc
- << " tests.\n";
- tlog << " Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
if (fails) {
+ tlog << " Log1p failed: " << fails << "/" << count << "/" << cc
+ << " tests.\n";
+ tlog << " Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
EXPECT_MPFR_MATCH(mpfr::Operation::Log1p, mx, mr, 0.5, rounding_mode);
}
};