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