Guard testing of tuple extensions to make tests portable

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-05-27 22:41:45 +00:00
parent 7515c69b11
commit 1f21fcd10a
5 changed files with 16 additions and 2 deletions

View File

@@ -82,6 +82,8 @@ void test_default_constructible_extension_sfinae()
MoveOnly, Tuple, MoveOnly, MoveOnly MoveOnly, Tuple, MoveOnly, MoveOnly
>::value, ""); >::value, "");
} }
// testing extensions
#ifdef _LIBCPP_VERSION
{ {
typedef std::tuple<MoveOnly, int> Tuple; typedef std::tuple<MoveOnly, int> Tuple;
typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple; typedef std::tuple<MoveOnly, Tuple, MoveOnly, MoveOnly> NestedTuple;
@@ -96,6 +98,7 @@ void test_default_constructible_extension_sfinae()
MoveOnly, Tuple, MoveOnly, MoveOnly MoveOnly, Tuple, MoveOnly, MoveOnly
>::value, ""); >::value, "");
} }
#endif
} }
int main() int main()
@@ -118,6 +121,7 @@ int main()
assert(std::get<2>(t) == 2); assert(std::get<2>(t) == 2);
} }
// extensions // extensions
#ifdef _LIBCPP_VERSION
{ {
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0), std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
MoveOnly(1)); MoveOnly(1));
@@ -131,7 +135,8 @@ int main()
assert(std::get<1>(t) == MoveOnly()); assert(std::get<1>(t) == MoveOnly());
assert(std::get<2>(t) == MoveOnly()); assert(std::get<2>(t) == MoveOnly());
} }
#if _LIBCPP_STD_VER > 11 #endif
#if TEST_STD_VER > 11
{ {
constexpr std::tuple<Empty> t0{Empty()}; constexpr std::tuple<Empty> t0{Empty()};
} }

View File

@@ -52,6 +52,8 @@ int main()
assert(alloc_last::allocator_constructed); assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 2); assert(std::get<0>(t) == 2);
} }
// testing extensions
#ifdef _LIBCPP_VERSION
{ {
typedef std::tuple<alloc_first, alloc_last> T; typedef std::tuple<alloc_first, alloc_last> T;
T t0(2, 3); T t0(2, 3);
@@ -75,4 +77,5 @@ int main()
assert(std::get<1>(t) == 2); assert(std::get<1>(t) == 2);
assert(std::get<2>(t) == 3); assert(std::get<2>(t) == 3);
} }
#endif
} }

View File

@@ -53,6 +53,8 @@ int main()
assert(alloc_last::allocator_constructed); assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 1); assert(std::get<0>(t) == 1);
} }
// testing extensions
#ifdef _LIBCPP_VERSION
{ {
typedef std::tuple<MoveOnly, alloc_first> T; typedef std::tuple<MoveOnly, alloc_first> T;
T t0(0 ,1); T t0(0 ,1);
@@ -74,4 +76,5 @@ int main()
assert(std::get<1>(t) == 2); assert(std::get<1>(t) == 2);
assert(std::get<2>(t) == 3); assert(std::get<2>(t) == 3);
} }
#endif
} }

View File

@@ -136,7 +136,8 @@ int main()
assert(std::get<2>(t) == 2); assert(std::get<2>(t) == 2);
assert(std::get<3>(t) == 3); assert(std::get<3>(t) == 3);
} }
// extensions // extensions
#ifdef _LIBCPP_VERSION
{ {
std::tuple<int, char*, std::string> t(2); std::tuple<int, char*, std::string> t(2);
assert(std::get<0>(t) == 2); assert(std::get<0>(t) == 2);
@@ -156,4 +157,5 @@ int main()
assert(std::get<2>(t) == "text"); assert(std::get<2>(t) == "text");
assert(std::get<3>(t) == 0.0); assert(std::get<3>(t) == 0.0);
} }
#endif
} }

View File

@@ -18,6 +18,7 @@
// LWG #2212 says that tuple_size and tuple_element must be // LWG #2212 says that tuple_size and tuple_element must be
// available after including <utility> // available after including <utility>
#include <cstddef>
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>