summaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/vector.bool
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
commit61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch)
treeec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/containers/sequences/vector.bool
parentf857581820d15e410e9945d2fcd5f7163be25a96 (diff)
Notes
Diffstat (limited to 'test/std/containers/sequences/vector.bool')
-rw-r--r--test/std/containers/sequences/vector.bool/assign_copy.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/vector.bool/assign_move.pass.cpp81
-rw-r--r--test/std/containers/sequences/vector.bool/capacity.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/construct_default.pass.cpp70
-rw-r--r--test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp55
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size.pass.cpp64
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp37
-rw-r--r--test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp39
-rw-r--r--test/std/containers/sequences/vector.bool/copy.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp62
-rw-r--r--test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp49
-rw-r--r--test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector.bool/emplace.pass.cpp68
-rw-r--r--test/std/containers/sequences/vector.bool/emplace_back.pass.cpp57
-rw-r--r--test/std/containers/sequences/vector.bool/erase_iter.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp85
-rw-r--r--test/std/containers/sequences/vector.bool/find.pass.cpp40
-rw-r--r--test/std/containers/sequences/vector.bool/initializer_list.pass.cpp41
-rw-r--r--test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp44
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp65
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp126
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp81
-rw-r--r--test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp77
-rw-r--r--test/std/containers/sequences/vector.bool/iterators.pass.cpp123
-rw-r--r--test/std/containers/sequences/vector.bool/move.pass.cpp64
-rw-r--r--test/std/containers/sequences/vector.bool/move_alloc.pass.cpp77
-rw-r--r--test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp51
-rw-r--r--test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp43
-rw-r--r--test/std/containers/sequences/vector.bool/push_back.pass.cpp48
-rw-r--r--test/std/containers/sequences/vector.bool/reserve.pass.cpp54
-rw-r--r--test/std/containers/sequences/vector.bool/resize_size.pass.cpp50
-rw-r--r--test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp52
-rw-r--r--test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp38
-rw-r--r--test/std/containers/sequences/vector.bool/swap.pass.cpp98
-rw-r--r--test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp90
-rw-r--r--test/std/containers/sequences/vector.bool/types.pass.cpp72
-rw-r--r--test/std/containers/sequences/vector.bool/vector_bool.pass.cpp52
40 files changed, 2467 insertions, 0 deletions
diff --git a/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
new file mode 100644
index 0000000000000..9501799ae3d0b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..2925fbc66745b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/assign_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
new file mode 100644
index 0000000000000..df98c817fd593
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
+ 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/vector.bool/capacity.pass.cpp b/test/std/containers/sequences/vector.bool/capacity.pass.cpp
new file mode 100644
index 0000000000000..63bff25f9f9ac
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/capacity.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
new file mode 100644
index 0000000000000..07824098fc6f7
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test0()
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
+#endif
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+#if TEST_STD_VER >= 11
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+#if TEST_STD_VER > 14
+ static_assert((noexcept(C{typename C::allocator_type{}})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
+#endif
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ test0<std::vector<bool> >();
+ test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
+ }
+#if TEST_STD_VER >= 11
+ {
+ test0<std::vector<bool, min_allocator<bool>> >();
+ test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..94e6801825d81
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+ C c(first, last);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool> >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(a, an);
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000000000..ea9d41d342f8d
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ {
+ std::allocator<bool> alloc;
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(a, an, alloc);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<bool> alloc;
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(a, an, alloc);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
new file mode 100644
index 0000000000000..93ecbe87c380f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+ C c(n, a);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+ C c(n);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == typename C::allocator_type());
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<bool> >(50);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50);
+ test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
new file mode 100644
index 0000000000000..fc772f10dfc43
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+ C c(n, x);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3);
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
new file mode 100644
index 0000000000000..6cca948ed834f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+ const typename C::allocator_type& a)
+{
+ C c(n, x, a);
+ assert(c.__invariants());
+ assert(a == c.get_allocator());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3, std::allocator<bool>());
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/copy.pass.cpp b/test/std/containers/sequences/vector.bool/copy.pass.cpp
new file mode 100644
index 0000000000000..58822782ff8b9
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/copy.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ unsigned s = x.size();
+ C c(x);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<bool>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an));
+ }
+ {
+ std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
new file mode 100644
index 0000000000000..2f0192b995ad7
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/copy_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ unsigned s = x.size();
+ C c(x, a);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an), std::allocator<bool>());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
+ }
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
new file mode 100644
index 0000000000000..b94588ead93be
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<bool>()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#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::vector<bool> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000000000..682e74ef03c20
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector<bool>() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#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::vector<bool> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp
new file mode 100644
index 0000000000000..f3fd1e9926f03
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
new file mode 100644
index 0000000000000..57aa47822f8ad
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/emplace_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector.bool
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
new file mode 100644
index 0000000000000..cbf26dd570a50
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..2c2c4cc48616b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+1, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+2, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+1, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+2, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp
new file mode 100644
index 0000000000000..75567a9b7bbc3
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/find.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// std::find with vector<bool>::iterator
+
+// http://llvm.org/bugs/show_bug.cgi?id=16816
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,true);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,false);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+}
diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
new file mode 100644
index 0000000000000..b9b4686544973
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000000000..aea3ad763cde8
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
+ assert(d.get_allocator() == test_allocator<bool>(3));
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
+ assert(d.get_allocator() == min_allocator<bool>());
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..c081cc81c5922
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d(10, true);
+ std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d(10, true);
+ std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..e51f8b589c7f7
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000000000..710ad4885f099
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
new file mode 100644
index 0000000000000..51c4626de0d02
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/insert_iter_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/test/std/containers/sequences/vector.bool/iterators.pass.cpp
new file mode 100644
index 0000000000000..c54fa4a80a95d
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/iterators.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::vector<bool>::iterator ii1{}, ii2{};
+ std::vector<bool>::iterator ii4 = ii1;
+ std::vector<bool>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp
new file mode 100644
index 0000000000000..e877292ced770
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > 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/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
new file mode 100644
index 0000000000000..deee932619711
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(5));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<bool>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000000000..b580eb4ae3b09
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#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::vector<bool> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
new file mode 100644
index 0000000000000..132186b555f25
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/move_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#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::vector<bool> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ // In C++17, move constructors for allocators are not allowed to throw
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_move_constructible<C>::value, "");
+#else
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+#endif
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..ef3dc5d10796c
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/op_equal_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/test/std/containers/sequences/vector.bool/push_back.pass.cpp
new file mode 100644
index 0000000000000..c6b0fbf418536
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/push_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/test/std/containers/sequences/vector.bool/reserve.pass.cpp
new file mode 100644
index 0000000000000..be717a3be8a8e
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
new file mode 100644
index 0000000000000..f75720c94ea39
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/resize_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
new file mode 100644
index 0000000000000..8cecf44d2fb0f
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/resize_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert(v == std::vector<bool>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert((v == std::vector<bool, min_allocator<bool>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000000000..1f9fcac3d9bf5
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/shrink_to_fit.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/swap.pass.cpp b/test/std/containers/sequences/vector.bool/swap.pass.cpp
new file mode 100644
index 0000000000000..a92c6a6c165fe
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/swap.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v1(100);
+ std::vector<bool> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef test_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(1));
+ assert(v2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(2));
+ assert(v2.get_allocator() == A(1));
+ }
+ {
+ std::vector<bool> v(2);
+ std::vector<bool>::reference r1 = v[0];
+ std::vector<bool>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v1(100);
+ std::vector<bool, min_allocator<bool>> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef min_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A());
+ std::vector<bool, A> v2(200, false, A());
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A());
+ assert(v2.get_allocator() == A());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(2);
+ std::vector<bool, min_allocator<bool>>::reference r1 = v[0];
+ std::vector<bool, min_allocator<bool>>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
new file mode 100644
index 0000000000000..6f36473fa989b
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+//
+// In C++17, the standard says that swap shall have:
+// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
+// allocator_traits<Allocator>::is_always_equal::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct some_alloc2
+{
+ typedef T value_type;
+
+ some_alloc2() {}
+ some_alloc2(const some_alloc2&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::false_type propagate_on_container_swap;
+ typedef std::true_type is_always_equal;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ C c1, c2;
+#if TEST_STD_VER >= 14
+ // In c++14, if POCS is set, swapping the allocator is required not to throw
+ static_assert( noexcept(swap(c1, c2)), "");
+#else
+ static_assert(!noexcept(swap(c1, c2)), "");
+#endif
+ }
+#if TEST_STD_VER >= 14
+ {
+ typedef std::vector<bool, some_alloc2<bool>> C;
+ C c1, c2;
+ // if the allocators are always equal, then the swap can be noexcept
+ static_assert( noexcept(swap(c1, c2)), "");
+ }
+#endif
+
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/types.pass.cpp b/test/std/containers/sequences/vector.bool/types.pass.cpp
new file mode 100644
index 0000000000000..b266b3bbb927e
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class Allocator>
+// class vector<bool, Allocator
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class Allocator>
+void
+test()
+{
+ typedef std::vector<bool, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, bool>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<test_allocator<bool> >();
+ test<std::allocator<bool> >();
+ static_assert((std::is_same<std::vector<bool>::allocator_type,
+ std::allocator<bool> >::value), "");
+#if __cplusplus >= 201103L
+ test<min_allocator<bool> >();
+#endif
+}
diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
new file mode 100644
index 0000000000000..a78f4fd590beb
--- /dev/null
+++ b/test/std/containers/sequences/vector.bool/vector_bool.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <vector>
+#include <cassert>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<bool> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_same<H::argument_type, T>::value), "" );
+ static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::vector<bool, min_allocator<bool>> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+ H>::value), "");
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#endif
+}