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 // operator/(const complex<T>& lhs, const complex<T>& rhs); // constexpr in C++20
15 // ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=5000000
20 #include "test_macros.h"
28 const std::complex<T
> lhs(-4.0, 7.5);
29 const std::complex<T
> rhs(1.5, 2.5);
30 assert(lhs
/ rhs
== std::complex<T
>(1.5, 2.5));
38 const unsigned N
= sizeof(testcases
) / sizeof(testcases
[0]);
39 int classification
[N
];
40 for (unsigned i
=0; i
< N
; ++i
)
41 classification
[i
] = classify(testcases
[i
]);
43 for (unsigned i
= 0; i
< N
; ++i
) {
44 for (unsigned j
= 0; j
< N
; ++j
) {
45 std::complex<double> r
= testcases
[i
] / testcases
[j
];
46 switch (classification
[i
]) {
48 switch (classification
[j
]) {
50 assert(classify(r
) == NaN
);
53 assert(classify(r
) == zero
);
56 assert(classify(r
) == zero
);
59 assert(classify(r
) == NaN
);
62 assert(classify(r
) == NaN
);
67 switch (classification
[j
]) {
69 assert(classify(r
) == inf
);
72 assert(classify(r
) == non_zero
);
75 assert(classify(r
) == zero
);
78 assert(classify(r
) == NaN
);
81 assert(classify(r
) == NaN
);
86 switch (classification
[j
]) {
88 assert(classify(r
) == inf
);
91 assert(classify(r
) == inf
);
94 assert(classify(r
) == NaN
);
97 assert(classify(r
) == NaN
);
100 assert(classify(r
) == NaN
);
105 switch (classification
[j
]) {
107 assert(classify(r
) == NaN
);
110 assert(classify(r
) == NaN
);
113 assert(classify(r
) == NaN
);
116 assert(classify(r
) == NaN
);
119 assert(classify(r
) == NaN
);
124 switch (classification
[j
]) {
126 assert(classify(r
) == inf
);
129 assert(classify(r
) == NaN
);
132 assert(classify(r
) == NaN
);
135 assert(classify(r
) == NaN
);
138 assert(classify(r
) == NaN
);
148 int main(int, char**)
155 #if TEST_STD_VER > 17
156 static_assert(test
<float>());
157 static_assert(test
<double>());
158 static_assert(test
<long double>());
159 static_assert(test_edges());