1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <complex>
11 
12 // complex& operator/=(const complex& rhs);
13 
14 #include <complex>
15 #include <cassert>
16 
17 template <class T>
18 void
test()19 test()
20 {
21     std::complex<T> c(-4, 7.5);
22     const std::complex<T> c2(1.5, 2.5);
23     assert(c.real() == -4);
24     assert(c.imag() == 7.5);
25     c /= c2;
26     assert(c.real() == 1.5);
27     assert(c.imag() == 2.5);
28     c /= c2;
29     assert(c.real() == 1);
30     assert(c.imag() == 0);
31 
32     std::complex<T> c3;
33 
34     c3 = c;
35     std::complex<int> ic (1,1);
36     c3 /= ic;
37     assert(c3.real() ==  0.5);
38     assert(c3.imag() == -0.5);
39 
40     c3 = c;
41     std::complex<float> fc (1,1);
42     c3 /= fc;
43     assert(c3.real() ==  0.5);
44     assert(c3.imag() == -0.5);
45 
46 }
47 
main()48 int main()
49 {
50     test<float>();
51     test<double>();
52     test<long double>();
53 }
54