summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/container.adaptors/queue/queue.defn
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/containers/container.adaptors/queue/queue.defn')
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp33
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp42
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp26
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp25
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp26
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp23
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp58
14 files changed, 458 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
new file mode 100644
index 00000000000..e9afa0b8c61
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(const queue& q);
+
+#include <queue>
+#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::queue<int> q(make<std::deque<int> >(5));
+ std::queue<int> q2;
+ q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
new file mode 100644
index 00000000000..828c0b78dc6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& q);
+
+#include <queue>
+#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::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::queue<MoveOnly> q2;
+ 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/queue/queue.defn/back.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
new file mode 100644
index 00000000000..e91edc28308
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference back();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.back();
+ assert(ir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
new file mode 100644
index 00000000000..f2696e903fe
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference back() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.back();
+ assert(cir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
new file mode 100644
index 00000000000..1d9c08b156b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<Emplaceable> q;
+ q.emplace(1, 2.5);
+ q.emplace(2, 3.5);
+ q.emplace(3, 4.5);
+ assert(q.size() == 3);
+ assert(q.front() == Emplaceable(1, 2.5));
+ assert(q.back() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
new file mode 100644
index 00000000000..deac5fa4d0e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
new file mode 100644
index 00000000000..4fbbb005386
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference front();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.front();
+ assert(ir == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
new file mode 100644
index 00000000000..253a27817eb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference front() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.front();
+ assert(cir == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
new file mode 100644
index 00000000000..3da2d122f34
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 2);
+ assert(q.front() == 2);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 1);
+ assert(q.front() == 3);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp
new file mode 100644
index 00000000000..9d462954c29
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ q.push(1);
+ assert(q.size() == 1);
+ assert(q.front() == 1);
+ assert(q.back() == 1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.front() == 1);
+ assert(q.back() == 2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
new file mode 100644
index 00000000000..11883d8cf70
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q;
+ q.push(MoveOnly(1));
+ assert(q.size() == 1);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(1));
+ q.push(MoveOnly(2));
+ assert(q.size() == 2);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(2));
+ q.push(MoveOnly(3));
+ assert(q.size() == 3);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
new file mode 100644
index 00000000000..1c72408f469
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
new file mode 100644
index 00000000000..e0744939748
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ q1.swap(q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
new file mode 100644
index 00000000000..cc918a36170
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = deque<T>>
+// class queue
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// ...
+// };
+
+#include <queue>
+#include <type_traits>
+
+struct test
+ : private std::queue<int>
+{
+ test()
+ {
+ c.push_back(1);
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
OpenPOWER on IntegriCloud