aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/math/logf_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/src/math/logf_test.cpp')
-rw-r--r--libc/test/src/math/logf_test.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp
index 7658075..fb99080 100644
--- a/libc/test/src/math/logf_test.cpp
+++ b/libc/test/src/math/logf_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/logf.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 LlvmLibcLogfTest = LIBC_NAMESPACE::testing::FPTest<float>;
@@ -28,7 +34,11 @@ TEST_F(LlvmLibcLogfTest, SpecialNumbers) {
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(-0.0f),
FE_DIVBYZERO);
EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(-1.0f), FE_INVALID);
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+ EXPECT_TRUE(0.0f == LIBC_NAMESPACE::logf(1.0f));
+#else
EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::logf(1.0f));
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
}
TEST_F(LlvmLibcLogfTest, TrickyInputs) {
@@ -73,7 +83,7 @@ TEST_F(LlvmLibcLogfTest, TrickyInputs) {
for (int i = 0; i < N; ++i) {
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
- LIBC_NAMESPACE::logf(x), 0.5);
+ LIBC_NAMESPACE::logf(x), TOLERANCE + 0.5);
}
}