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; 23 assert(c.real() == 0); 24 assert(c.imag() == 0); 25 c += 1.5; 26 assert(c.real() == 1.5); 27 assert(c.imag() == 0); 28 c += 1.5; 29 assert(c.real() == 3); 30 assert(c.imag() == 0); 31 c += -1.5; 32 assert(c.real() == 1.5); 33 assert(c.imag() == 0); 34 } 35 main(int,char **)36int main(int, char**) 37 { 38 test<float>(); 39 test<double>(); 40 test<long double>(); 41 42 return 0; 43 } 44