1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
//===-- Unittests for sincos ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "hdr/errno_macros.h"
#include "src/math/sincos.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
using LlvmLibcSincosTest = LIBC_NAMESPACE::testing::FPTest<double>;
TEST_F(LlvmLibcSincosTest, SpecialNumbers) {
double sin_x, cos_x;
LIBC_NAMESPACE::sincos(sNaN, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);
EXPECT_MATH_ERRNO(0);
LIBC_NAMESPACE::sincos(aNaN, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);
LIBC_NAMESPACE::sincos(zero, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(1.0, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(0.0, sin_x);
LIBC_NAMESPACE::sincos(neg_zero, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(1.0, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(neg_zero, sin_x);
LIBC_NAMESPACE::sincos(inf, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);
EXPECT_MATH_ERRNO(EDOM);
LIBC_NAMESPACE::sincos(neg_inf, &sin_x, &cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x);
EXPECT_MATH_ERRNO(EDOM);
LIBC_NAMESPACE::sincos(0x1.0p-28, &sin_x, &cos_x);
EXPECT_FP_EQ(1.0, cos_x);
EXPECT_FP_EQ(0x1.0p-28, sin_x);
}
|