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