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