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 // complex& operator=(const complex&);
12 // template<class X> complex& operator= (const complex<X>&);
13 
14 #include <complex>
15 #include <cassert>
16 
17 template <class T, class X>
18 void
19 test()
20 {
21     std::complex<T> c;
22     assert(c.real() == 0);
23     assert(c.imag() == 0);
24     std::complex<T> c2(1.5, 2.5);
25     c = c2;
26     assert(c.real() == 1.5);
27     assert(c.imag() == 2.5);
28     std::complex<X> c3(3.5, -4.5);
29     c = c3;
30     assert(c.real() == 3.5);
31     assert(c.imag() == -4.5);
32 }
33 
34 int main(int, char**)
35 {
36     test<float, float>();
37     test<float, double>();
38     test<float, long double>();
39 
40     test<double, float>();
41     test<double, double>();
42     test<double, long double>();
43 
44     test<long double, float>();
45     test<long double, double>();
46     test<long double, long double>();
47 
48   return 0;
49 }
50