Use C++11 static_assert in variant tests. Patch from Michael Park
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291021 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -72,45 +72,45 @@ void test_copy_ctor_sfinae() {
|
||||
void test_copy_ctor_basic() {
|
||||
{
|
||||
constexpr std::variant<int> v(std::in_place_index<0>, 42);
|
||||
static_assert(v.index() == 0);
|
||||
static_assert(v.index() == 0, "");
|
||||
constexpr std::variant<int> v2 = v;
|
||||
static_assert(v2.index() == 0);
|
||||
static_assert(std::get<0>(v2) == 42);
|
||||
static_assert(v2.index() == 0, "");
|
||||
static_assert(std::get<0>(v2) == 42, "");
|
||||
}
|
||||
{
|
||||
constexpr std::variant<int, long> v(std::in_place_index<1>, 42);
|
||||
static_assert(v.index() == 1);
|
||||
static_assert(v.index() == 1, "");
|
||||
constexpr std::variant<int, long> v2 = v;
|
||||
static_assert(v2.index() == 1);
|
||||
static_assert(std::get<1>(v2) == 42);
|
||||
static_assert(v2.index() == 1, "");
|
||||
static_assert(std::get<1>(v2) == 42, "");
|
||||
}
|
||||
{
|
||||
constexpr std::variant<TCopy> v(std::in_place_index<0>, 42);
|
||||
static_assert(v.index() == 0);
|
||||
static_assert(v.index() == 0, "");
|
||||
constexpr std::variant<TCopy> v2(v);
|
||||
static_assert(v2.index() == 0);
|
||||
static_assert(std::get<0>(v2).value == 42);
|
||||
static_assert(v2.index() == 0, "");
|
||||
static_assert(std::get<0>(v2).value == 42, "");
|
||||
}
|
||||
{
|
||||
constexpr std::variant<int, TCopy> v(std::in_place_index<1>, 42);
|
||||
static_assert(v.index() == 1);
|
||||
static_assert(v.index() == 1, "");
|
||||
constexpr std::variant<int, TCopy> v2(v);
|
||||
static_assert(v2.index() == 1);
|
||||
static_assert(std::get<1>(v2).value == 42);
|
||||
static_assert(v2.index() == 1, "");
|
||||
static_assert(std::get<1>(v2).value == 42, "");
|
||||
}
|
||||
{
|
||||
constexpr std::variant<TCopyNTMove> v(std::in_place_index<0>, 42);
|
||||
static_assert(v.index() == 0);
|
||||
static_assert(v.index() == 0, "");
|
||||
constexpr std::variant<TCopyNTMove> v2(v);
|
||||
static_assert(v2.index() == 0);
|
||||
static_assert(std::get<0>(v2).value == 42);
|
||||
static_assert(v2.index() == 0, "");
|
||||
static_assert(std::get<0>(v2).value == 42, "");
|
||||
}
|
||||
{
|
||||
constexpr std::variant<int, TCopyNTMove> v(std::in_place_index<1>, 42);
|
||||
static_assert(v.index() == 1);
|
||||
static_assert(v.index() == 1, "");
|
||||
constexpr std::variant<int, TCopyNTMove> v2(v);
|
||||
static_assert(v2.index() == 1);
|
||||
static_assert(std::get<1>(v2).value == 42);
|
||||
static_assert(v2.index() == 1, "");
|
||||
static_assert(std::get<1>(v2).value == 42, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 0);
|
||||
static_assert(result.value == 42);
|
||||
static_assert(result.index == 0, "");
|
||||
static_assert(result.value == 42, "");
|
||||
}
|
||||
{
|
||||
struct {
|
||||
@@ -94,8 +94,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 1);
|
||||
static_assert(result.value == 42);
|
||||
static_assert(result.index == 1, "");
|
||||
static_assert(result.value == 42, "");
|
||||
}
|
||||
{
|
||||
struct {
|
||||
@@ -106,8 +106,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 0);
|
||||
static_assert(result.value.value == 42);
|
||||
static_assert(result.index == 0, "");
|
||||
static_assert(result.value.value == 42, "");
|
||||
}
|
||||
{
|
||||
struct {
|
||||
@@ -118,8 +118,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 1);
|
||||
static_assert(result.value.value == 42);
|
||||
static_assert(result.index == 1, "");
|
||||
static_assert(result.value.value == 42, "");
|
||||
}
|
||||
{
|
||||
struct {
|
||||
@@ -130,8 +130,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 0);
|
||||
static_assert(result.value.value == 42);
|
||||
static_assert(result.index == 0, "");
|
||||
static_assert(result.value.value == 42, "");
|
||||
}
|
||||
{
|
||||
struct {
|
||||
@@ -142,8 +142,8 @@ void test_move_ctor_basic() {
|
||||
}
|
||||
} test;
|
||||
constexpr auto result = test();
|
||||
static_assert(result.index == 1);
|
||||
static_assert(result.value.value == 42);
|
||||
static_assert(result.index == 1, "");
|
||||
static_assert(result.value.value == 42, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user