diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2010-09-05 01:14:30 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2010-09-05 01:14:30 +0000 |
| commit | cbf93f39592428fc01f0c92196c6abf35dc4ed42 (patch) | |
| tree | 97d12422d41120001132cdcafc2d442ce0ab86ed /libcxx/test/containers/container.adaptors/queue | |
| parent | f9e81f9acbdd07281775fcf8cfcdd2b6a218da19 (diff) | |
| download | bcm5719-llvm-cbf93f39592428fc01f0c92196c6abf35dc4ed42.tar.gz bcm5719-llvm-cbf93f39592428fc01f0c92196c6abf35dc4ed42.zip | |
sync with N3126
llvm-svn: 113101
Diffstat (limited to 'libcxx/test/containers/container.adaptors/queue')
28 files changed, 1043 insertions, 0 deletions
diff --git a/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp new file mode 100644 index 00000000000..4e231b50e49 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp new file mode 100644 index 00000000000..cdb4fcfc7d8 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp new file mode 100644 index 00000000000..d8316243a5c --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp new file mode 100644 index 00000000000..951160dd8a1 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp new file mode 100644 index 00000000000..c080f5f8803 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp new file mode 100644 index 00000000000..72012ae12b1 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp new file mode 100644 index 00000000000..e03df240261 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp new file mode 100644 index 00000000000..6c90cc24b4f --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp new file mode 100644 index 00000000000..c7e4b86b823 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp new file mode 100644 index 00000000000..16a2faadc65 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp new file mode 100644 index 00000000000..cdb87a5bfe0 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue& operator=(const queue& q); + +#include <queue> +#include <cassert> + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::queue<int> q(make<std::deque<int> >(5)); + std::queue<int> q2; + q2 = q; + assert(q2 == q); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp new file mode 100644 index 00000000000..e655c3216ef --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// queue& operator=(queue&& q); + +#include <queue> +#include <cassert> + +#include "../../../../MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(MoveOnly(i)); + return c; +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5)); + std::queue<MoveOnly> q2; + q2 = std::move(q); + assert(q2.size() == 5); + assert(q.empty()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp new file mode 100644 index 00000000000..60f3e2cb236 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// reference back(); + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + int& ir = q.back(); + assert(ir == 3); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp new file mode 100644 index 00000000000..48240bc32e6 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// const_reference back() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::queue<int>& cqr = q; + const int& cir = cqr.back(); + assert(cir == 3); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp new file mode 100644 index 00000000000..eda8b937cf3 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// template <class... Args> void emplace(Args&&... args); + +#include <queue> +#include <cassert> + +#include "../../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::queue<Emplaceable> q; + q.emplace(1, 2.5); + q.emplace(2, 3.5); + q.emplace(3, 4.5); + assert(q.size() == 3); + assert(q.front() == Emplaceable(1, 2.5)); + assert(q.back() == Emplaceable(3, 4.5)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp new file mode 100644 index 00000000000..200754d345d --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// bool empty() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.empty()); + q.push(1); + assert(!q.empty()); + q.pop(); + assert(q.empty()); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp new file mode 100644 index 00000000000..15712f51849 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// reference front(); + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + int& ir = q.front(); + assert(ir == 1); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp new file mode 100644 index 00000000000..114241282c8 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// const_reference front() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::queue<int>& cqr = q; + const int& cir = cqr.front(); + assert(cir == 1); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp new file mode 100644 index 00000000000..90533dfc4c3 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// void pop(); + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + assert(q.size() == 3); + assert(q.front() == 1); + assert(q.back() == 3); + q.pop(); + assert(q.size() == 2); + assert(q.front() == 2); + assert(q.back() == 3); + q.pop(); + assert(q.size() == 1); + assert(q.front() == 3); + assert(q.back() == 3); + q.pop(); + assert(q.size() == 0); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp new file mode 100644 index 00000000000..46bcd117c3c --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// void push(const value_type& v); + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + q.push(1); + assert(q.size() == 1); + assert(q.front() == 1); + assert(q.back() == 1); + q.push(2); + assert(q.size() == 2); + assert(q.front() == 1); + assert(q.back() == 2); + q.push(3); + assert(q.size() == 3); + assert(q.front() == 1); + assert(q.back() == 3); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp new file mode 100644 index 00000000000..88cf26455fc --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// void push(value_type&& v); + +#include <queue> +#include <cassert> + +#include "../../../../MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::queue<MoveOnly> q; + q.push(MoveOnly(1)); + assert(q.size() == 1); + assert(q.front() == MoveOnly(1)); + assert(q.back() == MoveOnly(1)); + q.push(MoveOnly(2)); + assert(q.size() == 2); + assert(q.front() == MoveOnly(1)); + assert(q.back() == MoveOnly(2)); + q.push(MoveOnly(3)); + assert(q.size() == 3); + assert(q.front() == MoveOnly(1)); + assert(q.back() == MoveOnly(3)); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp new file mode 100644 index 00000000000..5b42a80643f --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// size_type size() const; + +#include <queue> +#include <cassert> + +int main() +{ + std::queue<int> q; + assert(q.size() == 0); + q.push(1); + assert(q.size() == 1); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp new file mode 100644 index 00000000000..d7846af6da6 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// void swap(queue& q); + +#include <queue> +#include <cassert> + +template <class C> +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::queue<int> q1 = make<std::queue<int> >(5); + std::queue<int> q2 = make<std::queue<int> >(10); + std::queue<int> q1_save = q1; + std::queue<int> q2_save = q2; + q1.swap(q2); + assert(q1 == q2_save); + assert(q2 == q1_save); +} diff --git a/libcxx/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp new file mode 100644 index 00000000000..2c00b1f868f --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp new file mode 100644 index 00000000000..0c3c1f86dc2 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp new file mode 100644 index 00000000000..a139c28684e --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp b/libcxx/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp new file mode 100644 index 00000000000..f208909959c --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/libcxx/test/containers/container.adaptors/queue/version.pass.cpp b/libcxx/test/containers/container.adaptors/queue/version.pass.cpp new file mode 100644 index 00000000000..7d05d8ce9c6 --- /dev/null +++ b/libcxx/test/containers/container.adaptors/queue/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <queue> + +#include <queue> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |

