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 T& rhs); 12 13 #include <complex> 14 #include <cassert> 15 16 #include "test_macros.h" 17 18 template <class T> 19 void test()20test() 21 { 22 std::complex<T> c(1); 23 assert(c.real() == 1); 24 assert(c.imag() == 0); 25 c /= 0.5; 26 assert(c.real() == 2); 27 assert(c.imag() == 0); 28 c /= 0.5; 29 assert(c.real() == 4); 30 assert(c.imag() == 0); 31 c /= -0.5; 32 assert(c.real() == -8); 33 assert(c.imag() == 0); 34 c.imag(2); 35 c /= 0.5; 36 assert(c.real() == -16); 37 assert(c.imag() == 4); 38 } 39 main(int,char **)40int main(int, char**) 41 { 42 test<float>(); 43 test<double>(); 44 test<long double>(); 45 46 return 0; 47 } 48