1 | //===-- Unittests for 10^x ------------------------------------------------===// |
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/errno/libc_errno.h" |
12 | #include "src/math/exp10.h" |
13 | #include "test/UnitTest/FPMatcher.h" |
14 | #include "test/UnitTest/Test.h" |
15 | |
16 | #include <errno.h> |
17 | #include <stdint.h> |
18 | |
19 | using LlvmLibcExp10Test = LIBC_NAMESPACE::testing::FPTest<double>; |
20 | |
21 | TEST_F(LlvmLibcExp10Test, SpecialNumbers) { |
22 | EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp10(aNaN)); |
23 | EXPECT_FP_EQ(inf, LIBC_NAMESPACE::exp10(inf)); |
24 | EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::exp10(neg_inf)); |
25 | EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp10(-0x1.0p20), |
26 | FE_UNDERFLOW); |
27 | EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10(0x1.0p20), |
28 | FE_OVERFLOW); |
29 | EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(0.0)); |
30 | EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(-0.0)); |
31 | |
32 | EXPECT_FP_EQ_ALL_ROUNDING(10.0, LIBC_NAMESPACE::exp10(1.0)); |
33 | EXPECT_FP_EQ_ALL_ROUNDING(100.0, LIBC_NAMESPACE::exp10(2.0)); |
34 | EXPECT_FP_EQ_ALL_ROUNDING(1000.0, LIBC_NAMESPACE::exp10(3.0)); |
35 | } |
36 | |