[libc++] NFC: Add regression tests for some <tuple> PRs that have been fixed
authorLouis Dionne <ldionne.2@gmail.com>
Tue, 8 Jun 2021 16:12:04 +0000 (12:12 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 8 Jun 2021 16:17:10 +0000 (12:17 -0400)
libcxx/test/std/utilities/tuple/tuple.tuple/PR27375.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp [new file with mode: 0644]

diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/PR27375.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/PR27375.pass.cpp
new file mode 100644 (file)
index 0000000..8560313
--- /dev/null
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Regression test for https://llvm.org/PR27375
+
+// UNSUPPORTED: c++03
+
+#include <tuple>
+
+int main(int, char**) {
+    std::tuple<int&>(std::tuple<int&&>(42));
+
+    return 0;
+}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp
new file mode 100644 (file)
index 0000000..7fb0e89
--- /dev/null
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Regression test for https://llvm.org/PR38601
+
+// UNSUPPORTED: c++03
+
+#include <cassert>
+#include <tuple>
+
+using Base = std::tuple<int, int>;
+
+struct Derived : Base {
+    template <class ...Ts>
+    Derived(int x, Ts... ts): Base(ts...), x_(x) { }
+    operator int () const { return x_; }
+    int x_;
+};
+
+int main() {
+    Derived d(1, 2, 3);
+    Base b = static_cast<Base>(d);
+    assert(std::get<0>(b) == 2);
+    assert(std::get<1>(b) == 3);
+    return 0;
+}