llvm-project/libcxx/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp

82 lines
1.5 KiB
C++
Raw Normal View History

2010-05-12 03:42:16 +08:00
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
2010-05-12 03:42:16 +08:00
//
2010-11-17 06:09:02 +08:00
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
2010-05-12 03:42:16 +08:00
//
//===----------------------------------------------------------------------===//
// <complex>
// template<class T>
// bool
// operator==(const T& lhs, const complex<T>& rhs);
#include <complex>
#include <cassert>
template <class T>
void
test_constexpr()
2010-05-12 03:42:16 +08:00
{
#if _LIBCPP_STD_VER > 11
{
constexpr T lhs(-2.5);
constexpr std::complex<T> rhs(1.5, 2.5);
static_assert(!(lhs == rhs), "");
}
{
constexpr T lhs(-2.5);
constexpr std::complex<T> rhs(1.5, 0);
static_assert(!(lhs == rhs), "");
}
{
constexpr T lhs(1.5);
constexpr std::complex<T> rhs(1.5, 2.5);
static_assert(!(lhs == rhs), "");
}
{
constexpr T lhs(1.5);
constexpr std::complex<T> rhs(1.5, 0);
static_assert(lhs == rhs, "");
}
#endif
2010-05-12 03:42:16 +08:00
}
template <class T>
void
test()
{
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 2.5);
assert(!(lhs == rhs));
2010-05-12 03:42:16 +08:00
}
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 0);
assert(!(lhs == rhs));
2010-05-12 03:42:16 +08:00
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 2.5);
assert(!(lhs == rhs));
2010-05-12 03:42:16 +08:00
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 0);
assert(lhs == rhs);
2010-05-12 03:42:16 +08:00
}
test_constexpr<T> ();
2010-05-12 03:42:16 +08:00
}
int main()
{
test<float>();
test<double>();
test<long double>();
// test_constexpr<int>();
2010-05-12 03:42:16 +08:00
}