summaryrefslogtreecommitdiff
path: root/test/std/utilities/tuple/tuple.tuple/tuple.elem
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.elem')
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp2
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp6
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp38
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp1
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp27
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp27
8 files changed, 44 insertions, 111 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
index e21768cb6f5f..002ad148ad6d 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
@@ -36,7 +36,7 @@ int main()
assert(std::get<0>(t) == "high");
assert(std::get<1>(t) == 5);
}
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
{
typedef std::tuple<double, int> T;
constexpr T t(2.718, 5);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
index 1c2b17ad8832..86d1191db556 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
@@ -21,7 +21,9 @@
#include <string>
#include <cassert>
-#if __cplusplus > 201103L
+#include "test_macros.h"
+
+#if TEST_STD_VER > 11
struct Empty {};
@@ -69,7 +71,7 @@ int main()
assert(std::get<2>(t) == 4);
assert(d == 2.5);
}
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
{ // get on an rvalue tuple
static_assert ( std::get<0> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 0, "" );
static_assert ( std::get<1> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 1, "" );
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
new file mode 100644
index 000000000000..74e6efd983bd
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <tuple>
+#include <string>
+
+struct UserType {};
+
+void test_bad_index() {
+ std::tuple<long, long, char, std::string, char, UserType, char> t1;
+ (void)std::get<int>(t1); // expected-error@tuple:* {{type not found}}
+ (void)std::get<long>(t1); // expected-note {{requested here}}
+ (void)std::get<char>(t1); // expected-note {{requested here}}
+ // expected-error@tuple:* 2 {{type occurs more than once}}
+ std::tuple<> t0;
+ (void)std::get<char*>(t0); // expected-node {{requested here}}
+ // expected-error@tuple:* 1 {{type not in empty type list}}
+}
+
+void test_bad_return_type() {
+ typedef std::unique_ptr<int> upint;
+ std::tuple<upint> t;
+ upint p = std::get<upint>(t); // expected-error{{deleted copy constructor}}
+}
+
+int main()
+{
+ test_bad_index();
+ test_bad_return_type();
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
index b661a78de8db..01ee1ca1f434 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -11,6 +11,7 @@
#include <tuple>
#include <utility>
+#include <memory>
#include <string>
#include <complex>
#include <type_traits>
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
deleted file mode 100644
index 85c32ca6d495..000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03, c++11
-
-#include <tuple>
-#include <string>
-#include <complex>
-
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
- typedef std::complex<float> cf;
- auto t1 = std::make_tuple<int, std::string> ( 42, "Hi" );
- assert (( std::get<cf>(t1) == cf {1,2} )); // no such type
-#else
-#error
-#endif
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
deleted file mode 100644
index 0a8d5829d02b..000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03, c++11
-
-#include <tuple>
-#include <string>
-#include <complex>
-
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
- typedef std::complex<float> cf;
- auto t1 = std::make_tuple<int, int, std::string, cf> ( 42, 21, "Hi", { 1,2 } );
- assert ( std::get<int>(t1) == 42 ); // two ints here
-#else
-#error
-#endif
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
deleted file mode 100644
index 0a4550f387dc..000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03, c++11
-
-#include <tuple>
-#include <string>
-#include <complex>
-
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
- typedef std::complex<float> cf;
- auto t1 = std::make_tuple<double, int, std::string, cf, int> ( 42, 21, "Hi", { 1,2 } );
- assert ( std::get<int>(t1) == 42 ); // two ints here (one at the end)
-#else
-#error
-#endif
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
deleted file mode 100644
index ffc715fe9a5b..000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03, c++11
-
-#include <tuple>
-#include <string>
-#include <memory>
-
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
- typedef std::unique_ptr<int> upint;
- std::tuple<upint> t(upint(new int(4)));
- upint p = std::get<upint>(t);
-#else
-#error
-#endif
-}