]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / numerics / complex.number / complex.ops / scalar_equals_complex.pass.cpp
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 //   bool
14 //   operator==(const T& lhs, const complex<T>& rhs);
15
16 #include <complex>
17 #include <cassert>
18
19 #include "test_macros.h"
20
21 template <class T>
22 void
23 test_constexpr()
24 {
25 #if TEST_STD_VER > 11
26     {
27     constexpr T lhs(-2.5);
28     constexpr std::complex<T> rhs(1.5,  2.5);
29     static_assert(!(lhs == rhs), "");
30     }
31     {
32     constexpr T lhs(-2.5);
33     constexpr std::complex<T> rhs(1.5,  0);
34     static_assert(!(lhs == rhs), "");
35     }
36     {
37     constexpr T lhs(1.5);
38     constexpr std::complex<T> rhs(1.5, 2.5);
39     static_assert(!(lhs == rhs), "");
40     }
41     {
42     constexpr T lhs(1.5);
43     constexpr std::complex<T> rhs(1.5, 0);
44     static_assert(lhs == rhs, "");
45     }
46 #endif
47 }
48
49 template <class T>
50 void
51 test()
52 {
53     {
54     T lhs(-2.5);
55     std::complex<T> rhs(1.5,  2.5);
56     assert(!(lhs == rhs));
57     }
58     {
59     T lhs(-2.5);
60     std::complex<T> rhs(1.5,  0);
61     assert(!(lhs == rhs));
62     }
63     {
64     T lhs(1.5);
65     std::complex<T> rhs(1.5, 2.5);
66     assert(!(lhs == rhs));
67     }
68     {
69     T lhs(1.5);
70     std::complex<T> rhs(1.5, 0);
71     assert(lhs == rhs);
72     }
73
74     test_constexpr<T> ();
75 }
76
77 int main()
78 {
79     test<float>();
80     test<double>();
81     test<long double>();
82 //     test_constexpr<int>();
83 }