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