aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/container.adaptors/priority.queue/priqueue.cons
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/container.adaptors/priority.queue/priqueue.cons')
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp36
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp42
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp34
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp40
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp35
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp25
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp32
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp41
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp27
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp31
-rw-r--r--test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp31
16 files changed, 513 insertions, 0 deletions
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000000000..82e44b414f642
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.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>
+
+// priority_queue& operator=(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+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::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q;
+ q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
new file mode 100644
index 0000000000000..d43e53819975c
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/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>
+
+// priority_queue& operator=(priority_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::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q;
+ q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
new file mode 100644
index 0000000000000..f543b6379f150
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.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>
+
+// explicit priority_queue(const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
new file mode 100644
index 0000000000000..2c73cbc62c609
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// explicit priority_queue(const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+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::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
new file mode 100644
index 0000000000000..b61fb88a5a368
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// explicit priority_queue(const Compare& comp, container_type&& c);
+
+#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::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000000000..f1129bc1bbc11
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+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::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000000000..2bffe80ae11b3
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.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>
+
+// priority_queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<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/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..1aaa8a3c65933
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.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>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int> q(a, an);
+ assert(q.size() == an - a);
+ assert(q.top() == 8);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
new file mode 100644
index 0000000000000..17a698c15dff4
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.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>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last, const Compare& comp);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int, std::vector<int>, std::greater<int> >
+ q(a, an, std::greater<int>());
+ assert(q.size() == an - a);
+ assert(q.top() == 0);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
new file mode 100644
index 0000000000000..b44d7d38c6f48
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.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>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::vector<int> v(a, a+n/2);
+ std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
+ assert(q.size() == n);
+ assert(q.top() == 8);
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
new file mode 100644
index 0000000000000..7abe796e53ef7
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.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>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::priority_queue<MoveOnly> q(a+n/2, a+n,
+ std::less<MoveOnly>(),
+ std::vector<MoveOnly>(a, a+n/2));
+ assert(q.size() == n);
+ assert(q.top() == MoveOnly(8));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000000000..aac8403e59229
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_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::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000000000..cdfa58b585544
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// priority_queue()
+// noexcept(is_nothrow_default_constructible<container_type>::value &&
+// is_nothrow_default_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000000000..e3d071d9aad09
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~priority_queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000000000..590d82fe6da48
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// priority_queue& operator=(priority_queue&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value &&
+// is_nothrow_move_assignable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000000000..05ff253d31b42
--- /dev/null
+++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// priority_queue(priority_queue&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value &&
+// is_nothrow_move_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}