complex_equals_scalar.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. 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(const std::complex<T>& lhs, const T& rhs, bool x)
22{
23    assert((lhs == rhs) == x);
24}
25
26template <class T>
27void
28test()
29{
30    {
31    std::complex<T> lhs(1.5,  2.5);
32    T rhs(-2.5);
33    test(lhs, rhs, false);
34    }
35    {
36    std::complex<T> lhs(1.5,  0);
37    T rhs(-2.5);
38    test(lhs, rhs, false);
39    }
40    {
41    std::complex<T> lhs(1.5, 2.5);
42    T rhs(1.5);
43    test(lhs, rhs, false);
44    }
45    {
46    std::complex<T> lhs(1.5, 0);
47    T rhs(1.5);
48    test(lhs, rhs, true);
49    }
50}
51
52int main()
53{
54    test<float>();
55    test<double>();
56    test<long double>();
57}
58