• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Unittests for atanf -----------------------------------------------===//
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/atanf.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 LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;
20 
TEST_F(LlvmLibcAtanfTest,SpecialNumbers)21 TEST_F(LlvmLibcAtanfTest, SpecialNumbers) {
22   LIBC_NAMESPACE::libc_errno = 0;
23 
24   // TODO: Strengthen errno,exception checks and remove these assert macros
25   // after new matchers/test fixtures are added
26   // https://github.com/llvm/llvm-project/issues/90653
27   LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
28   EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanf(aNaN));
29   // TODO: Uncomment these checks later, RoundingMode affects running
30   // tests in this way https://github.com/llvm/llvm-project/issues/90653.
31   // EXPECT_FP_EXCEPTION(0);
32   EXPECT_MATH_ERRNO(0);
33 
34   LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
35   EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanf(0.0f));
36   // See above TODO
37   // EXPECT_FP_EXCEPTION(0);
38   EXPECT_MATH_ERRNO(0);
39 
40   LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
41   EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanf(-0.0f));
42   // See above TODO
43   // EXPECT_FP_EXCEPTION(0);
44   EXPECT_MATH_ERRNO(0);
45 }
46