1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <complex>
11
12 // template<class T>
13 // complex<T>
14 // operator-(const complex<T>& lhs, const complex<T>& rhs);
15
16 #include <complex>
17 #include <cassert>
18
19 template <class T>
20 void
test(const std::complex<T> & lhs,const std::complex<T> & rhs,std::complex<T> x)21 test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
22 {
23 assert(lhs - rhs == x);
24 }
25
26 template <class T>
27 void
test()28 test()
29 {
30 {
31 std::complex<T> lhs(1.5, 2.5);
32 std::complex<T> rhs(3.5, 4.5);
33 std::complex<T> x(-2.0, -2.0);
34 test(lhs, rhs, x);
35 }
36 {
37 std::complex<T> lhs(1.5, -2.5);
38 std::complex<T> rhs(-3.5, 4.5);
39 std::complex<T> x(5.0, -7.0);
40 test(lhs, rhs, x);
41 }
42 }
43
main()44 int main()
45 {
46 test<float>();
47 test<double>();
48 test<long double>();
49 }
50