1//===-- Unittests for atan ------------------------------------------------===//
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 "src/math/atan.h"
10#include "test/UnitTest/FPMatcher.h"
11#include "test/UnitTest/Test.h"
12
13using LlvmLibcAtanTest = LIBC_NAMESPACE::testing::FPTest<double>;
14
15TEST_F(LlvmLibcAtanTest, SpecialNumbers) {
16 EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atan(sNaN), FE_INVALID);
17 EXPECT_MATH_ERRNO(0);
18
19 EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atan(aNaN));
20 EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::atan(zero));
21 EXPECT_FP_EQ_ALL_ROUNDING(neg_zero, LIBC_NAMESPACE::atan(neg_zero));
22 // atan(+-Inf) = +- pi/2.
23 EXPECT_FP_EQ(0x1.921fb54442d18p0, LIBC_NAMESPACE::atan(inf));
24 EXPECT_FP_EQ(-0x1.921fb54442d18p0, LIBC_NAMESPACE::atan(neg_inf));
25 // atan(+-1) = +- pi/4.
26 EXPECT_FP_EQ(0x1.921fb54442d18p-1, LIBC_NAMESPACE::atan(1.0));
27 EXPECT_FP_EQ(-0x1.921fb54442d18p-1, LIBC_NAMESPACE::atan(-1.0));
28}
29

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