complex_equals_scalar.pass.cpp revision a61e6f87056106ff2393ff7f3b03422e05fdd3fa
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 complex<T>& lhs, const T& rhs);
15
16#include <complex>
17#include <cassert>
18
19template <class T>
20void
21test_constexpr()
22{
23#if _LIBCPP_STD_VER > 11
24    {
25    constexpr std::complex<T> lhs(1.5, 2.5);
26    constexpr T rhs(-2.5);
27    static_assert(!(lhs == rhs), "");
28    }
29    {
30    constexpr std::complex<T> lhs(1.5, 0);
31    constexpr T rhs(-2.5);
32    static_assert(!(lhs == rhs), "");
33    }
34    {
35    constexpr std::complex<T> lhs(1.5, 2.5);
36    constexpr T rhs(1.5);
37    static_assert(!(lhs == rhs), "");
38    }
39    {
40    constexpr std::complex<T> lhs(1.5, 0);
41    constexpr T rhs(1.5);
42    static_assert( (lhs == rhs), "");
43    }
44#endif
45}
46
47template <class T>
48void
49test()
50{
51    {
52    std::complex<T> lhs(1.5,  2.5);
53    T rhs(-2.5);
54    assert(!(lhs == rhs));
55    }
56    {
57    std::complex<T> lhs(1.5, 0);
58    T rhs(-2.5);
59    assert(!(lhs == rhs));
60    }
61    {
62    std::complex<T> lhs(1.5, 2.5);
63    T rhs(1.5);
64    assert(!(lhs == rhs));
65    }
66    {
67    std::complex<T> lhs(1.5, 0);
68    T rhs(1.5);
69    assert( (lhs == rhs));
70    }
71
72    test_constexpr<T> ();
73    }
74
75int main()
76{
77    test<float>();
78    test<double>();
79    test<long double>();
80//     test_constexpr<int> ();
81}
82