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