brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · e983083 Raw
69 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "hdr/math_macros.h"10#include "src/__support/FPUtil/FPBits.h"11#include "src/math/atanf.h"12#include "test/UnitTest/FPMatcher.h"13#include "test/UnitTest/Test.h"14 15#include "hdr/stdint_proxy.h"16 17using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;18 19TEST_F(LlvmLibcAtanfTest, SpecialNumbers) {20  EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanf(sNaN), FE_INVALID);21  EXPECT_MATH_ERRNO(0);22 23  // TODO: Strengthen errno,exception checks and remove these assert macros24  // after new matchers/test fixtures are added25  // https://github.com/llvm/llvm-project/issues/9065326  LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);27  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanf(aNaN));28  // TODO: Uncomment these checks later, RoundingMode affects running29  // tests in this way https://github.com/llvm/llvm-project/issues/90653.30  // EXPECT_FP_EXCEPTION(0);31  EXPECT_MATH_ERRNO(0);32 33  LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);34  EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanf(0.0f));35  // See above TODO36  // EXPECT_FP_EXCEPTION(0);37  EXPECT_MATH_ERRNO(0);38 39  LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);40  EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanf(-0.0f));41  // See above TODO42  // EXPECT_FP_EXCEPTION(0);43  EXPECT_MATH_ERRNO(0);44}45 46#ifdef LIBC_TEST_FTZ_DAZ47 48using namespace LIBC_NAMESPACE::testing;49 50TEST_F(LlvmLibcAtanfTest, FTZMode) {51  ModifyMXCSR mxcsr(FTZ);52 53  EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::atanf(min_denormal));54}55 56TEST_F(LlvmLibcAtanfTest, DAZMode) {57  ModifyMXCSR mxcsr(DAZ);58 59  EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::atanf(min_denormal));60}61 62TEST_F(LlvmLibcAtanfTest, FTZDAZMode) {63  ModifyMXCSR mxcsr(FTZ | DAZ);64 65  EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::atanf(min_denormal));66}67 68#endif69