diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/containers/container.adaptors | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) |
Notes
Diffstat (limited to 'test/std/containers/container.adaptors')
98 files changed, 3552 insertions, 0 deletions
diff --git a/test/std/containers/container.adaptors/nothing_to_do.pass.cpp b/test/std/containers/container.adaptors/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/containers/container.adaptors/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp new file mode 100644 index 0000000000000..b102f117d48fc --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// explicit priority_queue(const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator<int>& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test<int> q((test_allocator<int>(3))); + assert(q.c.get_allocator() == test_allocator<int>(3)); + assert(q.c.size() == 0); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp new file mode 100644 index 0000000000000..4d99fc14728bb --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// priority_queue(const Compare& comp, const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator<int>& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test<int> q(std::less<int>(), test_allocator<int>(3)); + assert(q.c.get_allocator() == test_allocator<int>(3)); + assert(q.c.size() == 0); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp new file mode 100644 index 0000000000000..66ca614126f4d --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// priority_queue(const Compare& comp, const container_type& c, +// const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator<int>& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + typedef std::vector<int, test_allocator<int> > C; + C v = make<C>(5); + test<int> q(std::less<int>(), v, test_allocator<int>(3)); + assert(q.c.get_allocator() == test_allocator<int>(3)); + assert(q.size() == 5); + assert(q.top() == 4); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp new file mode 100644 index 0000000000000..643b0c625abbb --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// priority_queue(const Compare& comp, container_type&& c, +// const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator<int>& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + typedef std::vector<int, test_allocator<int> > C; + test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3)); + assert(q.c.get_allocator() == test_allocator<int>(3)); + assert(q.size() == 5); + assert(q.top() == 4); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp new file mode 100644 index 0000000000000..a5a073c079be5 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.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 Alloc> +// priority_queue(const priority_queue& q, const Alloc& a); + +#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; +} + +#include "test_allocator.h" + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} + test(const test& q, const test_allocator<int>& a) : base(q, a) {} + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test<int> qo(std::less<int>(), + make<std::vector<int, test_allocator<int> > >(5), + test_allocator<int>(2)); + test<int> q(qo, test_allocator<int>(6)); + assert(q.size() == 5); + assert(q.c.get_allocator() == test_allocator<int>(6)); + assert(q.top() == int(4)); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp new file mode 100644 index 0000000000000..8bdf7db863e7b --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// priority_queue(priority_queue&& q, const Alloc& a); + +#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; +} + +#include "test_allocator.h" + +template <class T> +struct test + : public std::priority_queue<T, std::vector<T, test_allocator<T> > > +{ + typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const value_compare& comp, const test_allocator<int>& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator<int>& a) : base(comp, c, a) {} + test(const value_compare& comp, container_type&& c, + const test_allocator<int>& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} + test_allocator<int> get_allocator() {return c.get_allocator();} + + using base::c; +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test<MoveOnly> qo(std::less<MoveOnly>(), + make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5), + test_allocator<MoveOnly>(2)); + test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6)); + assert(q.size() == 5); + assert(q.c.get_allocator() == test_allocator<MoveOnly>(6)); + assert(q.top() == MoveOnly(4)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} 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 +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp new file mode 100644 index 0000000000000..4f14e93f5f529 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.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> + +// priority_queue(); + +// template <class... Args> void emplace(Args&&... args); + +#include <queue> +#include <cassert> + +#include "../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::priority_queue<Emplaceable> q; + q.emplace(1, 2.5); + assert(q.top() == Emplaceable(1, 2.5)); + q.emplace(3, 4.5); + assert(q.top() == Emplaceable(3, 4.5)); + q.emplace(2, 3.5); + assert(q.top() == Emplaceable(3, 4.5)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp new file mode 100644 index 0000000000000..f0c914a04271c --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.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(); + +// bool empty() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q; + assert(q.empty()); + q.push(1); + assert(!q.empty()); + q.pop(); + assert(q.empty()); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp new file mode 100644 index 0000000000000..f41b26f68fb94 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.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> + +// priority_queue(); + +// void pop(); + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q; + q.push(1); + assert(q.top() == 1); + q.push(3); + assert(q.top() == 3); + q.push(2); + assert(q.top() == 3); + q.pop(); + assert(q.top() == 2); + q.pop(); + assert(q.top() == 1); + q.pop(); + assert(q.empty()); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp new file mode 100644 index 0000000000000..288e858f93f71 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// priority_queue(); + +// void push(const value_type& v); + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q; + q.push(1); + assert(q.top() == 1); + q.push(3); + assert(q.top() == 3); + q.push(2); + assert(q.top() == 3); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp new file mode 100644 index 0000000000000..4b20a9bf905f6 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.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> + +// priority_queue(); + +// void push(value_type&& v); + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::priority_queue<MoveOnly> q; + q.push(1); + assert(q.top() == 1); + q.push(3); + assert(q.top() == 3); + q.push(2); + assert(q.top() == 3); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp new file mode 100644 index 0000000000000..0ed579e060bbe --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.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(); + +// size_type size() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q; + assert(q.size() == 0); + q.push(1); + assert(q.size() == 1); + q.pop(); + assert(q.size() == 0); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp new file mode 100644 index 0000000000000..397d67fab521c --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.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> + +// priority_queue(); + +// void swap(priority_queue& q); + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q1; + std::priority_queue<int> q2; + q1.push(1); + q1.push(3); + q1.push(2); + q1.swap(q2); + assert(q1.empty()); + assert(q2.size() == 3); + assert(q2.top() == 3); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp new file mode 100644 index 0000000000000..eddbb926d20f2 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// priority_queue(); + +// const_reference top() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q; + q.push(1); + assert(q.top() == 1); + q.push(3); + assert(q.top() == 3); + q.push(2); + assert(q.top() == 3); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp new file mode 100644 index 0000000000000..1a828adde351e --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.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> + +// priority_queue(); + +// template <class T, class Container, class Compare> +// void swap(priority_queue<T, Container, Compare>& x, +// priority_queue<T, Container, Compare>& y); + +#include <queue> +#include <cassert> + +int main() +{ + std::priority_queue<int> q1; + std::priority_queue<int> q2; + q1.push(1); + q1.push(3); + q1.push(2); + swap(q1, q2); + assert(q1.empty()); + assert(q2.size() == 3); + assert(q2.top() == 3); +} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp new file mode 100644 index 0000000000000..4d2b441c60ee1 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.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 swap(priority_queue& c) +// noexcept(__is_nothrow_swappable<container_type>::value && +// __is_nothrow_swappable<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; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/priority.queue/types.pass.cpp b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp new file mode 100644 index 0000000000000..ade20d47d4e36 --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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 = vector<T>, +// class Compare = less<typename Container::value_type>> +// class priority_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; +// Compare comp; + +#include <queue> +#include <cassert> +#include <type_traits> + +struct test + : private std::priority_queue<int> +{ + test() + { + c.push_back(1); + assert(comp(1, 2)); + } +}; + +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::priority_queue<int>::container_type, std::vector<int> >::value), ""); + static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), ""); + static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), ""); + static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), ""); + static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), ""); + static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), ""); + static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), ""); + static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), ""); + test t; +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp new file mode 100644 index 0000000000000..b3ee758182a57 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// explicit queue(const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +struct test + : private std::queue<int, std::deque<int, test_allocator<int> > > +{ + typedef std::queue<int, std::deque<int, test_allocator<int> > > base; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} +}; + +int main() +{ + test q(test_allocator<int>(3)); + assert(q.get_allocator() == test_allocator<int>(3)); +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp new file mode 100644 index 0000000000000..16ba1747dd8a2 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// queue(const container_type& c, const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque<int, test_allocator<int> > C; + +struct test + : public std::queue<int, C> +{ + typedef std::queue<int, C> base; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} +}; + +int main() +{ + C d = make<C>(5); + test q(d, test_allocator<int>(4)); + assert(q.get_allocator() == test_allocator<int>(4)); + assert(q.size() == 5); + for (int i = 0; i < d.size(); ++i) + { + assert(q.front() == d[i]); + q.pop(); + } +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp new file mode 100644 index 0000000000000..70eaa18f9e25a --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// queue(const queue& q, const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque<int, test_allocator<int> > C; + +template <class T> +struct test + : public std::queue<T, C> +{ + typedef std::queue<T, C> base; + typedef test_allocator<int> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(const test& q, const allocator_type& a) : base(q, a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +int main() +{ + test<int> q(make<C>(5), test_allocator<int>(4)); + test<int> q2(q, test_allocator<int>(5)); + assert(q2.get_allocator() == test_allocator<int>(5)); + assert(q2.size() == 5); +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp new file mode 100644 index 0000000000000..0163588efa509 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// queue(const container_type& c, const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" +#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; +} + +typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C; + +template <class T> +struct test + : public std::queue<T, C> +{ + typedef std::queue<T, C> base; + typedef test_allocator<MoveOnly> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {} + test(test&& q, const allocator_type& a) : base(std::move(q), a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); + assert(q.get_allocator() == test_allocator<MoveOnly>(4)); + assert(q.size() == 5); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp new file mode 100644 index 0000000000000..7237bf271b0c7 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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 Alloc> +// queue(queue&& q, const Alloc& a); + +#include <queue> +#include <cassert> + +#include "test_allocator.h" +#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; +} + +typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C; + +template <class T> +struct test + : public std::queue<T, C> +{ + typedef std::queue<T, C> base; + typedef test_allocator<MoveOnly> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {} + test(test&& q, const allocator_type& a) : base(std::move(q), a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); + test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5)); + assert(q2.get_allocator() == test_allocator<MoveOnly>(5)); + assert(q2.size() == 5); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp new file mode 100644 index 0000000000000..c4ab955c311b7 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// explicit queue(const container_type& c); + +#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::deque<int> d = make<std::deque<int> >(5); + std::queue<int> q(d); + assert(q.size() == 5); + for (int i = 0; i < d.size(); ++i) + { + assert(q.front() == d[i]); + q.pop(); + } +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp new file mode 100644 index 0000000000000..998f849797cd9 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue(const queue&) = default; + +#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 = q; + assert(q2 == q); +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp new file mode 100644 index 0000000000000..e6aadd39dd9b2 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue(); + +#include <queue> +#include <cassert> + +#include "../../../stack_allocator.h" + +int main() +{ + std::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.front() == 1); + assert(q.back() == 2); +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp new file mode 100644 index 0000000000000..8dd5d2f64ec36 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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> + +// queue(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 = std::move(q); + assert(q2.size() == 5); + assert(q.empty()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp new file mode 100644 index 0000000000000..f72067b0adcc6 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// explicit queue(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::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5)); + assert(q.size() == 5); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp new file mode 100644 index 0000000000000..392853432669b --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue() +// noexcept(is_nothrow_default_constructible<container_type>::value); + +// This tests a conforming extension + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue<MoveOnly> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp new file mode 100644 index 0000000000000..d9b8f731f28a7 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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> + +// ~queue() // implied noexcept; + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue<MoveOnly> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 0000000000000..beef0f12ffb73 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue& operator=(queue&& c) +// noexcept(is_nothrow_move_assignable<container_type>::value); + +// This tests a conforming extension + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue<MoveOnly> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp new file mode 100644 index 0000000000000..2402e609b9888 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue(queue&&) +// noexcept(is_nothrow_move_constructible<container_type>::value); + +// This tests a conforming extension + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue<MoveOnly> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp new file mode 100644 index 0000000000000..e9afa0b8c61f3 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp new file mode 100644 index 0000000000000..af1b7e20c338f --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp new file mode 100644 index 0000000000000..e91edc28308ed --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp new file mode 100644 index 0000000000000..f2696e903fe95 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp new file mode 100644 index 0000000000000..1d9c08b156b77 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp new file mode 100644 index 0000000000000..deac5fa4d0e29 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp new file mode 100644 index 0000000000000..4fbbb00538602 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp new file mode 100644 index 0000000000000..253a27817eb02 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp new file mode 100644 index 0000000000000..3da2d122f341c --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp new file mode 100644 index 0000000000000..9d462954c297a --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp new file mode 100644 index 0000000000000..d8992821f1f20 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp new file mode 100644 index 0000000000000..1c72408f469f1 --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp new file mode 100644 index 0000000000000..e07449397485b --- /dev/null +++ b/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/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp new file mode 100644 index 0000000000000..cc918a361707c --- /dev/null +++ b/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; +} diff --git a/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp b/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp new file mode 100644 index 0000000000000..a2ad32fec1474 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.ops/eq.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> + +// template <class T, class Container> +// bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); +// +// template <class T, class Container> +// bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); + +#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; + assert(q1 == q1_save); + assert(q1 != q2); + assert(q2 == q2_save); +} diff --git a/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp b/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp new file mode 100644 index 0000000000000..af08cbaca48e9 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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> +// bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); +// +// template <class T, class Container> +// bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); +// +// template <class T, class Container> +// bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); +// +// template <class T, class Container> +// bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); + +#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); + assert(q1 < q2); + assert(q2 > q1); + assert(q1 <= q2); + assert(q2 >= q1); +} diff --git a/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp b/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp new file mode 100644 index 0000000000000..a3f7c43b792b3 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.special/swap.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> + +// template <class T, class Container> +// void swap(queue<T, Container>& x, queue<T, Container>& y); + +#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; + swap(q1, q2); + assert(q1 == q2_save); + assert(q2 == q1_save); +} diff --git a/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp new file mode 100644 index 0000000000000..cfe4a1bb70768 --- /dev/null +++ b/test/std/containers/container.adaptors/queue/queue.special/swap_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> + +// void swap(queue& c) +// noexcept(__is_nothrow_swappable<container_type>::value); + +// This tests a conforming extension + +#include <queue> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue<MoveOnly> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/queue/version.pass.cpp b/test/std/containers/container.adaptors/queue/version.pass.cpp new file mode 100644 index 0000000000000..35b94b33c517d --- /dev/null +++ b/test/std/containers/container.adaptors/queue/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +#include <queue> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp new file mode 100644 index 0000000000000..94899d4f1b540 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class Alloc> +// explicit stack(const Alloc& a); + +#include <stack> +#include <cassert> + +#include "test_allocator.h" + +struct test + : private std::stack<int, std::deque<int, test_allocator<int> > > +{ + typedef std::stack<int, std::deque<int, test_allocator<int> > > base; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} +}; + +int main() +{ + test q(test_allocator<int>(3)); + assert(q.get_allocator() == test_allocator<int>(3)); +} diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp new file mode 100644 index 0000000000000..fe8622751c95c --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class Alloc> +// stack(const container_type& c, const Alloc& a); + +#include <stack> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque<int, test_allocator<int> > C; + +struct test + : public std::stack<int, C> +{ + typedef std::stack<int, C> base; + + explicit test(const test_allocator<int>& a) : base(a) {} + test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator<int> get_allocator() {return c.get_allocator();} +}; + +int main() +{ + C d = make<C>(5); + test q(d, test_allocator<int>(4)); + assert(q.get_allocator() == test_allocator<int>(4)); + 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/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp new file mode 100644 index 0000000000000..33cb4dd52b3c0 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class Alloc> +// stack(const stack& q, const Alloc& a); + +#include <stack> +#include <cassert> + +#include "test_allocator.h" + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(int(i)); + return c; +} + +typedef std::deque<int, test_allocator<int> > C; + +template <class T> +struct test + : public std::stack<T, C> +{ + typedef std::stack<T, C> base; + typedef test_allocator<int> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(const test& q, const allocator_type& a) : base(q, a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +int main() +{ + test<int> q(make<C>(5), test_allocator<int>(4)); + test<int> q2(q, test_allocator<int>(5)); + assert(q2.get_allocator() == test_allocator<int>(5)); + assert(q2.size() == 5); +} diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp new file mode 100644 index 0000000000000..374aa996ffe3d --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class Alloc> +// stack(const container_type& c, const Alloc& a); + +#include <stack> +#include <cassert> + +#include "test_allocator.h" +#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; +} + +typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C; + +template <class T> +struct test + : public std::stack<T, C> +{ + typedef std::stack<T, C> base; + typedef test_allocator<MoveOnly> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {} + test(test&& q, const allocator_type& a) : base(std::move(q), a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); + assert(q.get_allocator() == test_allocator<MoveOnly>(4)); + assert(q.size() == 5); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp new file mode 100644 index 0000000000000..5fa5bd2a8bd21 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class Alloc> +// stack(stack&& q, const Alloc& a); + +#include <stack> +#include <cassert> + +#include "test_allocator.h" +#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; +} + +typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C; + +template <class T> +struct test + : public std::stack<T, C> +{ + typedef std::stack<T, C> base; + typedef test_allocator<MoveOnly> allocator_type; + typedef typename base::container_type container_type; + + explicit test(const allocator_type& a) : base(a) {} + test(const container_type& c, const allocator_type& a) : base(c, a) {} + test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {} + test(test&& q, const allocator_type& a) : base(std::move(q), a) {} + allocator_type get_allocator() {return this->c.get_allocator();} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); + test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5)); + assert(q2.get_allocator() == test_allocator<MoveOnly>(5)); + assert(q2.size() == 5); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp new file mode 100644 index 0000000000000..9dc05013e3dd4 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp new file mode 100644 index 0000000000000..8673e06ce9306 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp new file mode 100644 index 0000000000000..523cd6811893a --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp new file mode 100644 index 0000000000000..44fab41a6c557 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp new file mode 100644 index 0000000000000..ab08da93831e6 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp new file mode 100644 index 0000000000000..bab55863b55f4 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp new file mode 100644 index 0000000000000..477bd57a6d102 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 0000000000000..dd836796dc170 --- /dev/null +++ b/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/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp new file mode 100644 index 0000000000000..cfc660b36def0 --- /dev/null +++ b/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 +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp new file mode 100644 index 0000000000000..38769e3fb0265 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// stack& operator=(const stack& q); + +#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; + q2 = q; + assert(q2 == q); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp new file mode 100644 index 0000000000000..75cbec1c47c8a --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// stack& operator=(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; + q2 = std::move(q); + assert(q2.size() == 5); + assert(q.empty()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp new file mode 100644 index 0000000000000..3573c220ece9f --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class... Args> void emplace(Args&&... args); + +#include <stack> +#include <cassert> + +#include "../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::stack<Emplaceable> q; + q.emplace(1, 2.5); + q.emplace(2, 3.5); + q.emplace(3, 4.5); + assert(q.size() == 3); + assert(q.top() == Emplaceable(3, 4.5)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp new file mode 100644 index 0000000000000..a4f728174132e --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// bool empty() const; + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + assert(q.empty()); + q.push(1); + assert(!q.empty()); + q.pop(); + assert(q.empty()); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp new file mode 100644 index 0000000000000..7ec1bf187ceae --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/pop.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// void pop(); + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + assert(q.size() == 3); + assert(q.top() == 3); + q.pop(); + assert(q.size() == 2); + assert(q.top() == 2); + q.pop(); + assert(q.size() == 1); + assert(q.top() == 1); + q.pop(); + assert(q.size() == 0); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp new file mode 100644 index 0000000000000..6d5c90890d2ee --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// void push(const value_type& v); + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + q.push(1); + assert(q.size() == 1); + assert(q.top() == 1); + q.push(2); + assert(q.size() == 2); + assert(q.top() == 2); + q.push(3); + assert(q.size() == 3); + assert(q.top() == 3); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp new file mode 100644 index 0000000000000..67d0ea3385f66 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// void push(value_type&& v); + +#include <stack> +#include <cassert> + +#include "MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::stack<MoveOnly> q; + q.push(MoveOnly(1)); + assert(q.size() == 1); + assert(q.top() == MoveOnly(1)); + q.push(MoveOnly(2)); + assert(q.size() == 2); + assert(q.top() == MoveOnly(2)); + q.push(MoveOnly(3)); + assert(q.size() == 3); + assert(q.top() == MoveOnly(3)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp new file mode 100644 index 0000000000000..2d8024729332f --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// size_type size() const; + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + assert(q.size() == 0); + q.push(1); + assert(q.size() == 1); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp new file mode 100644 index 0000000000000..50a29c48aa2f2 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// void swap(stack& q); + +#include <stack> +#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::stack<int> q1 = make<std::stack<int> >(5); + std::stack<int> q2 = make<std::stack<int> >(10); + std::stack<int> q1_save = q1; + std::stack<int> q2_save = q2; + q1.swap(q2); + assert(q1 == q2_save); + assert(q2 == q1_save); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp new file mode 100644 index 0000000000000..6bde162e3ebb1 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/top.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// reference top(); + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + int& ir = q.top(); + assert(ir == 3); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp new file mode 100644 index 0000000000000..8e43d05fc682a --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/top_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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// const_reference top() const; + +#include <stack> +#include <cassert> + +int main() +{ + std::stack<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::stack<int>& cqr = q; + const int& cir = cqr.top(); + assert(cir == 3); +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp new file mode 100644 index 0000000000000..afc5ebd537538 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class T, class Container = deque<T>> +// class stack +// { +// 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 <stack> +#include <vector> +#include <type_traits> + +struct test + : private std::stack<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::stack<int>::container_type, std::deque<int> >::value), ""); + static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), ""); + static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), ""); + static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), ""); + static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), ""); + static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), ""); + static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), ""); + static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), ""); + test t; +} diff --git a/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp b/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp new file mode 100644 index 0000000000000..9b041f7f8d158 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.ops/eq.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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// template <class T, class Container> +// bool operator==(const stack<T, Container>& x,const stack<T, Container>& y); +// +// template <class T, class Container> +// bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y); + +#include <stack> +#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::stack<int> q1 = make<std::stack<int> >(5); + std::stack<int> q2 = make<std::stack<int> >(10); + std::stack<int> q1_save = q1; + std::stack<int> q2_save = q2; + assert(q1 == q1_save); + assert(q1 != q2); + assert(q2 == q2_save); +} diff --git a/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp b/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp new file mode 100644 index 0000000000000..beb937d4c12e0 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template <class T, class Container> +// bool operator< (const stack<T, Container>& x,const stack<T, Container>& y); +// +// template <class T, class Container> +// bool operator> (const stack<T, Container>& x,const stack<T, Container>& y); +// +// template <class T, class Container> +// bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y); +// +// template <class T, class Container> +// bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y); + +#include <stack> +#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::stack<int> q1 = make<std::stack<int> >(5); + std::stack<int> q2 = make<std::stack<int> >(10); + assert(q1 < q2); + assert(q2 > q1); + assert(q1 <= q2); + assert(q2 >= q1); +} diff --git a/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp b/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp new file mode 100644 index 0000000000000..90371146dc0b7 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.special/swap.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> + +// template <class T, class Container> +// void swap(stack<T, Container>& x, stack<T, Container>& y); + +#include <stack> +#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::stack<int> q1 = make<std::stack<int> >(5); + std::stack<int> q2 = make<std::stack<int> >(10); + std::stack<int> q1_save = q1; + std::stack<int> q2_save = q2; + swap(q1, q2); + assert(q1 == q2_save); + assert(q2 == q1_save); +} diff --git a/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp new file mode 100644 index 0000000000000..80e024f5f1e07 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.special/swap_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. +// +//===----------------------------------------------------------------------===// + +// <stack> + +// void swap(stack& c) +// noexcept(__is_nothrow_swappable<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; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/test/std/containers/container.adaptors/stack/version.pass.cpp b/test/std/containers/container.adaptors/stack/version.pass.cpp new file mode 100644 index 0000000000000..339d0f4dda8f7 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +#include <stack> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |