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