1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // sinh(const complex<T>& x);
18 #include "test_macros.h"
23 test(const std::complex<T
>& c
, std::complex<T
> x
)
32 test(std::complex<T
>(0, 0), std::complex<T
>(0, 0));
37 const unsigned N
= sizeof(testcases
) / sizeof(testcases
[0]);
38 for (unsigned i
= 0; i
< N
; ++i
)
40 std::complex<double> r
= sinh(testcases
[i
]);
41 if (testcases
[i
].real() == 0 && testcases
[i
].imag() == 0)
43 assert(r
.real() == 0);
44 assert(std::signbit(r
.real()) == std::signbit(testcases
[i
].real()));
45 assert(r
.imag() == 0);
46 assert(std::signbit(r
.imag()) == std::signbit(testcases
[i
].imag()));
48 else if (testcases
[i
].real() == 0 && std::isinf(testcases
[i
].imag()))
50 assert(r
.real() == 0);
51 assert(std::isnan(r
.imag()));
53 else if (std::isfinite(testcases
[i
].real()) && std::isinf(testcases
[i
].imag()))
55 assert(std::isnan(r
.real()));
56 assert(std::isnan(r
.imag()));
58 else if (testcases
[i
].real() == 0 && std::isnan(testcases
[i
].imag()))
60 assert(r
.real() == 0);
61 assert(std::isnan(r
.imag()));
63 else if (std::isfinite(testcases
[i
].real()) && std::isnan(testcases
[i
].imag()))
65 assert(std::isnan(r
.real()));
66 assert(std::isnan(r
.imag()));
68 else if (std::isinf(testcases
[i
].real()) && testcases
[i
].imag() == 0)
70 assert(std::isinf(r
.real()));
71 assert(std::signbit(r
.real()) == std::signbit(testcases
[i
].real()));
72 assert(r
.imag() == 0);
73 assert(std::signbit(r
.imag()) == std::signbit(testcases
[i
].imag()));
75 else if (std::isinf(testcases
[i
].real()) && std::isfinite(testcases
[i
].imag()))
77 assert(std::isinf(r
.real()));
78 assert(std::signbit(r
.real()) == std::signbit(testcases
[i
].real() * cos(testcases
[i
].imag())));
79 assert(std::isinf(r
.imag()));
80 assert(std::signbit(r
.imag()) == std::signbit(sin(testcases
[i
].imag())));
82 else if (std::isinf(testcases
[i
].real()) && std::isinf(testcases
[i
].imag()))
84 assert(std::isinf(r
.real()));
85 assert(std::isnan(r
.imag()));
87 else if (std::isinf(testcases
[i
].real()) && std::isnan(testcases
[i
].imag()))
89 assert(std::isinf(r
.real()));
90 assert(std::isnan(r
.imag()));
92 else if (std::isnan(testcases
[i
].real()) && testcases
[i
].imag() == 0)
94 assert(std::isnan(r
.real()));
95 assert(r
.imag() == 0);
96 assert(std::signbit(r
.imag()) == std::signbit(testcases
[i
].imag()));
98 else if (std::isnan(testcases
[i
].real()) && std::isfinite(testcases
[i
].imag()))
100 assert(std::isnan(r
.real()));
101 assert(std::isnan(r
.imag()));
103 else if (std::isnan(testcases
[i
].real()) && std::isnan(testcases
[i
].imag()))
105 assert(std::isnan(r
.real()));
106 assert(std::isnan(r
.imag()));
111 int main(int, char**)