brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · a98b931 Raw
50 lines · cpp
1//===-- Unittests for sincos ----------------------------------------------===//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 "src/math/sincos.h"11#include "test/UnitTest/FPMatcher.h"12#include "test/UnitTest/Test.h"13 14using LlvmLibcSincosTest = LIBC_NAMESPACE::testing::FPTest<double>;15 16TEST_F(LlvmLibcSincosTest, SpecialNumbers) {17  double sin_x, cos_x;18 19  LIBC_NAMESPACE::sincos(sNaN, &sin_x, &cos_x);20  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);21  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);22  EXPECT_MATH_ERRNO(0);23 24  LIBC_NAMESPACE::sincos(aNaN, &sin_x, &cos_x);25  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);26  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);27 28  LIBC_NAMESPACE::sincos(zero, &sin_x, &cos_x);29  EXPECT_FP_EQ_ALL_ROUNDING(1.0, cos_x);30  EXPECT_FP_EQ_ALL_ROUNDING(0.0, sin_x);31 32  LIBC_NAMESPACE::sincos(neg_zero, &sin_x, &cos_x);33  EXPECT_FP_EQ_ALL_ROUNDING(1.0, cos_x);34  EXPECT_FP_EQ_ALL_ROUNDING(neg_zero, sin_x);35 36  LIBC_NAMESPACE::sincos(inf, &sin_x, &cos_x);37  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);38  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);39  EXPECT_MATH_ERRNO(EDOM);40 41  LIBC_NAMESPACE::sincos(neg_inf, &sin_x, &cos_x);42  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);43  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);44  EXPECT_MATH_ERRNO(EDOM);45 46  LIBC_NAMESPACE::sincos(0x1.0p-28, &sin_x, &cos_x);47  EXPECT_FP_EQ(1.0, cos_x);48  EXPECT_FP_EQ(0x1.0p-28, sin_x);49}50