summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/tuple/tuple.tuple
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-02 03:18:30 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-02 03:18:30 +0000
commitf447e62e1d1007778cfc55c9df2111c8ac104e23 (patch)
tree2df97761ac8c85c7bf60461d50546bf203627891 /libcxx/test/std/utilities/tuple/tuple.tuple
parent32e8734e41722ed0a7c034deb274714340d43646 (diff)
downloadbcm5719-llvm-f447e62e1d1007778cfc55c9df2111c8ac104e23.tar.gz
bcm5719-llvm-f447e62e1d1007778cfc55c9df2111c8ac104e23.zip
Rewrite std::get<Type>(...) helper using constexpr functions.
llvm-svn: 274418
Diffstat (limited to 'libcxx/test/std/utilities/tuple/tuple.tuple')
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp35
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp23
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp23
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp23
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp23
5 files changed, 35 insertions, 92 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
new file mode 100644
index 00000000000..6375b77cd4a
--- /dev/null
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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}}
+}
+
+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/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
deleted file mode 100644
index f4a9e4fff9c..00000000000
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
+++ /dev/null
@@ -1,23 +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()
-{
- 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
-}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
deleted file mode 100644
index 89f83d64ef7..00000000000
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
+++ /dev/null
@@ -1,23 +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()
-{
- 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
-}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
deleted file mode 100644
index 6bcabc25450..00000000000
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
+++ /dev/null
@@ -1,23 +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()
-{
- 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)
-}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
deleted file mode 100644
index 8c6eba71bb5..00000000000
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
+++ /dev/null
@@ -1,23 +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()
-{
- typedef std::unique_ptr<int> upint;
- std::tuple<upint> t(upint(new int(4)));
- upint p = std::get<upint>(t);
-}
OpenPOWER on IntegriCloud