brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · b9cb261 Raw
62 lines · cpp
1//===-- Unittests for cospif ----------------------------------------------===//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/errno_macros.h"10#include "hdr/stdint_proxy.h"11#include "src/math/cospif.h"12#include "test/UnitTest/FPMatcher.h"13 14using LlvmLibcCospifTest = LIBC_NAMESPACE::testing::FPTest<float>;15 16TEST_F(LlvmLibcCospifTest, SpecialNumbers) {17  EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cospif(sNaN), FE_INVALID);18  EXPECT_MATH_ERRNO(0);19 20  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cospif(aNaN));21  EXPECT_MATH_ERRNO(0);22 23  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(0.0f));24  EXPECT_MATH_ERRNO(0);25 26  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(-0.0f));27  EXPECT_MATH_ERRNO(0);28 29  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cospif(inf));30  EXPECT_MATH_ERRNO(EDOM);31 32  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cospif(neg_inf));33  EXPECT_MATH_ERRNO(EDOM);34}35 36#ifdef LIBC_TEST_FTZ_DAZ37 38using namespace LIBC_NAMESPACE::testing;39 40TEST_F(LlvmLibcCospifTest, FTZMode) {41  ModifyMXCSR mxcsr(FTZ);42 43  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(min_denormal));44  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(max_denormal));45}46 47TEST_F(LlvmLibcCospifTest, DAZMode) {48  ModifyMXCSR mxcsr(DAZ);49 50  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(min_denormal));51  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(max_denormal));52}53 54TEST_F(LlvmLibcCospifTest, FTZDAZMode) {55  ModifyMXCSR mxcsr(FTZ | DAZ);56 57  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(min_denormal));58  EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cospif(max_denormal));59}60 61#endif62