1 | //===-- Unittests for sincosf ---------------------------------------------===// |
---|---|
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 "hdr/math_macros.h" |
10 | #include "src/__support/FPUtil/FPBits.h" |
11 | #include "src/__support/libc_errno.h" |
12 | #include "src/math/sincosf.h" |
13 | #include "test/UnitTest/FPMatcher.h" |
14 | #include "test/UnitTest/Test.h" |
15 | |
16 | #include <stdint.h> |
17 | |
18 | using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest<float>; |
19 | |
20 | TEST_F(LlvmLibcSinCosfTest, SpecialNumbers) { |
21 | libc_errno = 0; |
22 | float sin, cos; |
23 | |
24 | LIBC_NAMESPACE::sincosf(sNaN, &sin, &cos); |
25 | EXPECT_FP_EQ(aNaN, cos); |
26 | EXPECT_FP_EQ(aNaN, sin); |
27 | EXPECT_MATH_ERRNO(0); |
28 | |
29 | LIBC_NAMESPACE::sincosf(aNaN, &sin, &cos); |
30 | EXPECT_FP_EQ(aNaN, cos); |
31 | EXPECT_FP_EQ(aNaN, sin); |
32 | EXPECT_MATH_ERRNO(0); |
33 | |
34 | LIBC_NAMESPACE::sincosf(0.0f, &sin, &cos); |
35 | EXPECT_FP_EQ(1.0f, cos); |
36 | EXPECT_FP_EQ(0.0f, sin); |
37 | EXPECT_MATH_ERRNO(0); |
38 | |
39 | LIBC_NAMESPACE::sincosf(-0.0f, &sin, &cos); |
40 | EXPECT_FP_EQ(1.0f, cos); |
41 | EXPECT_FP_EQ(-0.0f, sin); |
42 | EXPECT_MATH_ERRNO(0); |
43 | |
44 | LIBC_NAMESPACE::sincosf(inf, &sin, &cos); |
45 | EXPECT_FP_EQ(aNaN, cos); |
46 | EXPECT_FP_EQ(aNaN, sin); |
47 | EXPECT_MATH_ERRNO(EDOM); |
48 | |
49 | LIBC_NAMESPACE::sincosf(neg_inf, &sin, &cos); |
50 | EXPECT_FP_EQ(aNaN, cos); |
51 | EXPECT_FP_EQ(aNaN, sin); |
52 | EXPECT_MATH_ERRNO(EDOM); |
53 | } |
54 |