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 void
test_constexpr()22 test_constexpr()
23 {
24 #if TEST_STD_VER > 11
25     {
26     constexpr std::complex<T> lhs(1.5, 2.5);
27     constexpr T rhs(-2.5);
28     static_assert(!(lhs == rhs), "");
29     }
30     {
31     constexpr std::complex<T> lhs(1.5, 0);
32     constexpr T rhs(-2.5);
33     static_assert(!(lhs == rhs), "");
34     }
35     {
36     constexpr std::complex<T> lhs(1.5, 2.5);
37     constexpr T rhs(1.5);
38     static_assert(!(lhs == rhs), "");
39     }
40     {
41     constexpr std::complex<T> lhs(1.5, 0);
42     constexpr T rhs(1.5);
43     static_assert( (lhs == rhs), "");
44     }
45 #endif
46 }
47 
48 template <class T>
49 void
test()50 test()
51 {
52     {
53     std::complex<T> lhs(1.5,  2.5);
54     T rhs(-2.5);
55     assert(!(lhs == rhs));
56     }
57     {
58     std::complex<T> lhs(1.5, 0);
59     T rhs(-2.5);
60     assert(!(lhs == rhs));
61     }
62     {
63     std::complex<T> lhs(1.5, 2.5);
64     T rhs(1.5);
65     assert(!(lhs == rhs));
66     }
67     {
68     std::complex<T> lhs(1.5, 0);
69     T rhs(1.5);
70     assert( (lhs == rhs));
71     }
72 
73     test_constexpr<T> ();
74     }
75 
main(int,char **)76 int main(int, char**)
77 {
78     test<float>();
79     test<double>();
80     test<long double>();
81 //     test_constexpr<int> ();
82 
83   return 0;
84 }
85