| 1 | //===----------------------------------------------------------------------===// |
| 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 | // <complex> |
| 10 | |
| 11 | // template<class T> |
| 12 | // bool |
| 13 | // operator!=(const complex<T>& lhs, const T& rhs); |
| 14 | |
| 15 | #include <complex> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | |
| 20 | template <class T> |
| 21 | TEST_CONSTEXPR_CXX20 |
| 22 | void |
| 23 | test_constexpr() |
| 24 | { |
| 25 | #if TEST_STD_VER > 11 |
| 26 | { |
| 27 | constexpr std::complex<T> lhs(1.5, 2.5); |
| 28 | constexpr T rhs(-2.5); |
| 29 | static_assert(lhs != rhs, "" ); |
| 30 | } |
| 31 | { |
| 32 | constexpr std::complex<T> lhs(1.5, 0); |
| 33 | constexpr T rhs(-2.5); |
| 34 | static_assert(lhs != rhs, "" ); |
| 35 | } |
| 36 | { |
| 37 | constexpr std::complex<T> lhs(1.5, 2.5); |
| 38 | constexpr T rhs(1.5); |
| 39 | static_assert(lhs != rhs, "" ); |
| 40 | } |
| 41 | { |
| 42 | constexpr std::complex<T> lhs(1.5, 0); |
| 43 | constexpr T rhs(1.5); |
| 44 | static_assert( !(lhs != rhs), "" ); |
| 45 | } |
| 46 | #endif |
| 47 | } |
| 48 | |
| 49 | template <class T> |
| 50 | TEST_CONSTEXPR_CXX20 |
| 51 | bool |
| 52 | test() |
| 53 | { |
| 54 | { |
| 55 | std::complex<T> lhs(1.5, 2.5); |
| 56 | T rhs(-2.5); |
| 57 | assert(lhs != rhs); |
| 58 | } |
| 59 | { |
| 60 | std::complex<T> lhs(1.5, 0); |
| 61 | T rhs(-2.5); |
| 62 | assert(lhs != rhs); |
| 63 | } |
| 64 | { |
| 65 | std::complex<T> lhs(1.5, 2.5); |
| 66 | T rhs(1.5); |
| 67 | assert(lhs != rhs); |
| 68 | } |
| 69 | { |
| 70 | std::complex<T> lhs(1.5, 0); |
| 71 | T rhs(1.5); |
| 72 | assert( !(lhs != rhs)); |
| 73 | } |
| 74 | |
| 75 | test_constexpr<T> (); |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | int main(int, char**) |
| 80 | { |
| 81 | test<float>(); |
| 82 | test<double>(); |
| 83 | test<long double>(); |
| 84 | |
| 85 | #if TEST_STD_VER > 17 |
| 86 | static_assert(test<float>()); |
| 87 | static_assert(test<double>()); |
| 88 | static_assert(test<long double>()); |
| 89 | #endif |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |