1//===-- Unittests for atan2f ----------------------------------------------===//
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/atan2f.h"
13#include "test/UnitTest/FPMatcher.h"
14#include "test/UnitTest/Test.h"
15
16using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest<float>;
17
18TEST_F(LlvmLibcAtan2fTest, SpecialNumbers) {
19 LIBC_NAMESPACE::libc_errno = 0;
20
21 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
22 EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atan2f(aNaN, zero));
23 EXPECT_FP_EXCEPTION(0);
24 EXPECT_MATH_ERRNO(0);
25
26 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
27 EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atan2f(1.0f, aNaN));
28 EXPECT_FP_EXCEPTION(0);
29 EXPECT_MATH_ERRNO(0);
30
31 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
32 EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atan2f(zero, zero));
33 EXPECT_FP_EXCEPTION(0);
34 EXPECT_MATH_ERRNO(0);
35
36 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
37 EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atan2f(-0.0f, zero));
38 EXPECT_FP_EXCEPTION(0);
39 EXPECT_MATH_ERRNO(0);
40
41 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
42 EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atan2f(1.0f, inf));
43 EXPECT_FP_EXCEPTION(0);
44 EXPECT_MATH_ERRNO(0);
45
46 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
47 EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atan2f(-1.0f, inf));
48 EXPECT_FP_EXCEPTION(0);
49 EXPECT_MATH_ERRNO(0);
50}
51

source code of libc/test/src/math/smoke/atan2f_test.cpp