1 | //===-- Unittests for logf-----------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "hdr/math_macros.h" |
10 | #include "src/__support/FPUtil/FPBits.h" |
11 | #include "src/math/logf.h" |
12 | #include "test/UnitTest/FPMatcher.h" |
13 | #include "test/UnitTest/Test.h" |
14 | |
15 | #include <stdint.h> |
16 | |
17 | using LlvmLibcLogfTest = LIBC_NAMESPACE::testing::FPTest<float>; |
18 | |
19 | TEST_F(LlvmLibcLogfTest, SpecialNumbers) { |
20 | EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::logf(aNaN)); |
21 | EXPECT_FP_EQ(inf, LIBC_NAMESPACE::logf(inf)); |
22 | EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(neg_inf), FE_INVALID); |
23 | EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(0.0f), |
24 | FE_DIVBYZERO); |
25 | EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(-0.0f), |
26 | FE_DIVBYZERO); |
27 | EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(-1.0f), FE_INVALID); |
28 | EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::logf(1.0f)); |
29 | } |
30 | |