summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/container.adaptors/stack/stack.cons
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/containers/container.adaptors/stack/stack.cons
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/containers/container.adaptors/stack/stack.cons')
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp28
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp41
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp39
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp30
9 files changed, 294 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
new file mode 100644
index 00000000000..9dc05013e3d
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(const container_type& c);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::deque<int> d = make<std::deque<int> >(5);
+ std::stack<int> q(d);
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.top() == d[d.size() - i - 1]);
+ q.pop();
+ }
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
new file mode 100644
index 00000000000..8673e06ce93
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(const stack&) = default;
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q(make<std::deque<int> >(5));
+ std::stack<int> q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
new file mode 100644
index 00000000000..523cd681189
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack();
+
+#include <stack>
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
new file mode 100644
index 00000000000..173bfc2fe09
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::stack<MoveOnly> q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 00000000000..a6c424d9abb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(container_type&& c);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..521d9567758
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack()
+// noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..c502012c8eb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// ~stack() // implied noexcept;
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..4952803d042
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..c9826834311
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
OpenPOWER on IntegriCloud