aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/list/list.cons
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/sequences/list/list.cons')
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp44
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp45
-rw-r--r--test/std/containers/sequences/list/list.cons/assign_move.pass.cpp82
-rw-r--r--test/std/containers/sequences/list/list.cons/copy.pass.cpp54
-rw-r--r--test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp42
-rw-r--r--test/std/containers/sequences/list/list.cons/default.pass.cpp58
-rw-r--r--test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp48
-rw-r--r--test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp46
-rw-r--r--test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp77
-rw-r--r--test/std/containers/sequences/list/list.cons/move.pass.cpp74
-rw-r--r--test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp78
-rw-r--r--test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp50
-rw-r--r--test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp44
-rw-r--r--test/std/containers/sequences/list/list.cons/size_type.pass.cpp103
-rw-r--r--test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp79
19 files changed, 1121 insertions, 0 deletions
diff --git a/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000000000..b851eb9dc5a01
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(const list& c);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..24bd140c4e4f8
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
new file mode 100644
index 0000000000000..0fd586f84af73
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/copy.pass.cpp b/test/std/containers/sequences/list/list.cons/copy.pass.cpp
new file mode 100644
index 0000000000000..530690a925d44
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ std::list<int> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ std::list<int, min_allocator<int>> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000000000..99fe9f115f949
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default.pass.cpp b/test/std/containers/sequences/list/list.cons/default.pass.cpp
new file mode 100644
index 0000000000000..c05bd74ca79e6
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l = {};
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000000000..2455fb39a79af
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
new file mode 100644
index 0000000000000..9d9946b68966a
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/default_stack_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 4> > l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000000000..ca7ade6d19cb1
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// ~list() // implied noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000000000..3307017989eb4
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000000000..4a85e378c1ce0
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
new file mode 100644
index 0000000000000..09eae8ab43c18
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class InputIterator>
+// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ std::allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ min_allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/move.pass.cpp b/test/std/containers/sequences/list/list.cons/move.pass.cpp
new file mode 100644
index 0000000000000..54209a55f7e22
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> l1 = {1, 2, 3};
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = std::move(l1);
+ assert(*l2.erase(i) == 2);
+ assert(l2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000000000..8f82702b296f4
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000000000..280d93d486e6d
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000000000..e436a29f5d472
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..7b7b8a327b886
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
new file mode 100644
index 0000000000000..75b93a3dfb6b6
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(size_type n);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::list<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(std::distance(d.begin(), d.end()) == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+
+int main()
+{
+ {
+ std::list<int> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::list<int, min_allocator<int> > C;
+ C l(3, min_allocator<int> ());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ C::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ test3<int, min_allocator<int>> (3);
+ }
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000000000..12da86da0a413
--- /dev/null
+++ b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(size_type n, const T& value, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l(3, 2, std::allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l(3, 2, min_allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#endif
+}