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 // proj(const complex<T>& x);
18 #include "test_macros.h"
23 test(const std::complex<T
>& z
, std::complex<T
> x
)
32 test(std::complex<T
>(1, 2), std::complex<T
>(1, 2));
33 test(std::complex<T
>(-1, 2), std::complex<T
>(-1, 2));
34 test(std::complex<T
>(1, -2), std::complex<T
>(1, -2));
35 test(std::complex<T
>(-1, -2), std::complex<T
>(-1, -2));
40 const unsigned N
= sizeof(testcases
) / sizeof(testcases
[0]);
41 for (unsigned i
= 0; i
< N
; ++i
)
43 std::complex<double> r
= proj(testcases
[i
]);
44 switch (classify(testcases
[i
]))
48 assert(r
== testcases
[i
]);
49 assert(std::signbit(real(r
)) == std::signbit(real(testcases
[i
])));
50 assert(std::signbit(imag(r
)) == std::signbit(imag(testcases
[i
])));
53 assert(std::isinf(real(r
)) && real(r
) > 0);
55 assert(std::signbit(imag(r
)) == std::signbit(imag(testcases
[i
])));
59 assert(classify(r
) == classify(testcases
[i
]));