[libcxx] r224658 - Move test into test/std subdirectory.
Eric Fiselier
eric at efcs.ca
Fri Dec 19 17:40:31 PST 2014
Added: libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,803 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 splice(const_iterator position, list& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,357 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 splice(const_iterator position, list& x, iterator first, iterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.ops/unique.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/unique.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/unique.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/unique.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void unique();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// template <class BinaryPred> void unique(BinaryPred pred);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+ return x == y;
+}
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include <__debug>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int>::iterator i1 = c1.begin();
+ std::list<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int, min_allocator<int>>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.special/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.special/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.special/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.special/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void swap(list& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<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() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// template <class T, class Alloc = allocator<T> >
+// class list
+// {
+// public:
+//
+// // types:
+// typedef T value_type;
+// typedef Alloc allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+
+#include <list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
+ static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
+ static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/list/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/version.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/containers/sequences/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/assign_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/assign_move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/assign_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/capacity.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/capacity.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/capacity.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/capacity.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_default.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test0()
+{
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+#if __cplusplus >= 201103L
+ 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)
+{
+ 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 __cplusplus >= 201103L
+ {
+ test0<std::vector<bool, min_allocator<bool>> >();
+ test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/emplace.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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);
+ }
+ }
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(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;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/push_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/push_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/push_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/push_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/reserve.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/reserve.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/reserve.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/reserve.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<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() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+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;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <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_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);
+ }
+#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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/asan.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/asan.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/asan.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/asan.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// reference operator[](size_type n);
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" void __asan_set_error_exit_code(int);
+
+int main()
+{
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ T foo = c[c.size()]; // bad, but not caught by ASAN
+ }
+#endif
+
+ __asan_set_error_exit_code(0);
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ assert(is_contiguous_container_asan_correct(c));
+ assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
+ T foo = c[c.size()]; // should trigger ASAN
+ assert(false); // if we got here, ASAN didn't trigger
+ }
+}
+#else
+int main () { return 0; }
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/asan_throw.pass.cc
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/asan_throw.pass.cc?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/asan_throw.pass.cc (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/asan_throw.pass.cc Fri Dec 19 19:40:03 2014
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Test asan vector annotations with a class that throws in a CTOR.
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+class X {
+public:
+ X(const X &x) { Init(x.a); }
+ X(char arg) { Init(arg); }
+ X() { Init(42); }
+ X &operator=(const X &x) {
+ Init(x.a);
+ return *this;
+ }
+ void Init(char arg) {
+ if (arg == 42)
+ throw 0;
+ if (arg == 66)
+ arg = 42;
+ a = arg;
+ }
+ char get() const { return a; }
+ void set(char arg) { a = arg; }
+
+private:
+ char a;
+};
+
+void test_push_back() {
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.push_back(X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace_back() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.emplace_back(42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.push_back(X(1));
+ v.push_back(X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {21, 42};
+ v.insert(v.end(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 3);
+ }
+ assert(v.size() == 3);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_insert() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.end(), X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.emplace(v.end(), 42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range2() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {10, 42};
+ v.insert(v.begin(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 4);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_insert_n() {
+ std::vector<X> v;
+ v.reserve(10);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.begin(), 1, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 3);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_resize() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_resize_param() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+int main() {
+ test_push_back();
+ test_emplace_back();
+ test_insert_range();
+ test_insert();
+ test_emplace();
+ test_insert_range2();
+ test_insert_n();
+ test_resize();
+ test_resize_param();
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/const_value_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/const_value_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/const_value_type.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/const_value_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 int> v; // an extension
+
+#include <vector>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::vector<const int> v = {1, 2, 3};
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/db_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_cback.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_cback.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_cback.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_cback.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_cfront.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_cfront.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_cfront.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_cfront.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_cindex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_cindex.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_cindex.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_cindex.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Index const vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_front.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_front.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_front.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_front.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_index.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_index.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_index.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_index.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// Index vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_3.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_3.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_3.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_4.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_4.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_4.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_5.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_5.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_5.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_6.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_6.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_6.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_7.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_7.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/db_iterators_8.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/db_iterators_8.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// 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"
+
+struct A
+{
+ int first;
+ int second;
+};
+
+int main()
+{
+ {
+ typedef int 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 int 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 int 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 int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int 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 int 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 int 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 int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+ {
+ typedef A T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c = {A{1, 2}};
+ C::iterator i = c.begin();
+ i->first = 3;
+ C::const_iterator j = i;
+ assert(j->first == 3);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::vector<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::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
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 T, class Allocator = allocator<T> >
+// class vector
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// 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 T, class Allocator>
+void
+test()
+{
+ typedef std::vector<T, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, T>::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 Allocator::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+ static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+ static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+ static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+ static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::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<int, test_allocator<int> >();
+ test<int*, std::allocator<int*> >();
+ test<Copyable, test_allocator<Copyable> >();
+ static_assert((std::is_same<std::vector<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> 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);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 250> > 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);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> 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);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<int> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(v == std::vector<int>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ assert((v == std::vector<int, min_allocator<int>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 401> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ {
+ std::vector<int, stack_allocator<int, 400> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 200);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v1(100);
+ std::vector<int> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v1(100);
+ std::vector<int, min_allocator<int>> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<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::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test0()
+{
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c));
+#if __cplusplus >= 201103L
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c1));
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ test0<std::vector<int> >();
+ test0<std::vector<NotConstructible> >();
+ test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
+ test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
+ (test_allocator<NotConstructible>(5));
+ }
+ {
+ std::vector<int, stack_allocator<int, 10> > v;
+ assert(v.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ test0<std::vector<int, min_allocator<int>> >();
+ test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
+ test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
+ test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
+ (min_allocator<NotConstructible>{});
+ }
+ {
+ std::vector<int, min_allocator<int> > v;
+ assert(v.empty());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.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));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+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<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+
+ test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator, class A>
+void
+test(Iterator first, Iterator last, const A& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+#if __cplusplus >= 201103L
+
+template <class T>
+struct implicit_conv_allocator : min_allocator<T>
+{
+ implicit_conv_allocator(void* p) {}
+ implicit_conv_allocator(const implicit_conv_allocator&) = default;
+};
+
+#endif
+
+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]);
+ std::allocator<int> alloc;
+ test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(a, an, alloc);
+ }
+#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]);
+ min_allocator<int> alloc;
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(a, an, alloc);
+ test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "asan_testing.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);
+ assert(is_contiguous_container_asan_correct(c));
+#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());
+ assert(is_contiguous_container_asan_correct(c));
+#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
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<int> >(50);
+ test<std::vector<DefaultOnly> >(500);
+ assert(DefaultOnly::count == 0);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50);
+ test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500);
+ test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23));
+ assert(DefaultOnly::count == 0);
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.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);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3);
+ test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3);
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.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);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3, std::allocator<int>());
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.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);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+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<int>(a, an));
+ }
+ {
+ std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<int>(-2));
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#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<int, min_allocator<int>>(a, an));
+ }
+ {
+ std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.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);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+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<int>(a, an), std::allocator<int>());
+ }
+ {
+ std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(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<int, min_allocator<int>>(a, an), min_allocator<int>());
+ }
+ {
+ std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// class vector
+// vector();
+
+#include <vector>
+
+struct X
+{
+ std::vector<X> q;
+};
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#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::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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() // implied noexcept;
+
+#include <vector>
+#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::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<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);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int>::const_iterator i = c1.begin();
+ std::vector<int> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
+ std::vector<int, min_allocator<int>> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<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));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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& 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 "../../../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::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#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::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// pointer data();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// const_pointer data() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ const std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ const std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 7> > c;
+ std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A> c1;
+ std::vector<A> c2;
+ std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A, min_allocator<A>> c1;
+ std::vector<A, min_allocator<A>> c2;
+ std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 4> > c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::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<int>(a1+1, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::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<int>(a1+2, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::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());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int> > outer(2, std::vector<int>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::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<int, min_allocator<int>>(a1+1, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::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<int, min_allocator<int>>(a1+2, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::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());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d(10, 1);
+ std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d(10, 1);
+ std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(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<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(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<int, stack_allocator<int, 308> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int, stack_allocator<int, 300> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v(100);
+ std::vector<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ 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);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 position, size_type n, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ 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 < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ 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 < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> c1(100);
+ std::vector<int> c2;
+ std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ 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 < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ 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 < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> c1(100);
+ std::vector<int, min_allocator<int>> c2;
+ std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 position, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0);
+ v.pop_back(); v.pop_back(); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ 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<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+#if _LIBCPP_DEBUG >= 1
+#include <cstdlib>
+#include <exception>
+
+#endif
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+ {
+ std::vector<int, stack_allocator<int, 15> > c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ std::vector<CMyClass> vec;
+
+ vec.push_back(instance);
+ std::vector<CMyClass> vec2(vec);
+ assert(is_contiguous_container_asan_correct(vec));
+ assert(is_contiguous_container_asan_correct(vec2));
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ assert(is_contiguous_container_asan_correct(vec));
+ }
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 push_back(value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int>::iterator i1 = c1.begin();
+ std::vector<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,187 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#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;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/sequences/vector/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/version.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/containers/stack_allocator.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/stack_allocator.h?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/stack_allocator.h (added)
+++ libcxx/trunk/test/std/containers/stack_allocator.h Fri Dec 19 19:40:03 2014
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef STACK_ALLOCATOR_H
+#define STACK_ALLOCATOR_H
+
+#include <cstddef>
+#include <new>
+
+template <class T, std::size_t N>
+class stack_allocator
+{
+ char buf_[sizeof(T)*N];
+ char* ptr_;
+public:
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ template <class U> struct rebind {typedef stack_allocator<U, N> other;};
+
+ stack_allocator() : ptr_(buf_) {}
+
+private:
+ stack_allocator(const stack_allocator&);// = delete;
+ stack_allocator& operator=(const stack_allocator&);// = delete;
+
+public:
+ pointer allocate(size_type n, const void* = 0)
+ {
+ if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ pointer r = (T*)ptr_;
+ ptr_ += n * sizeof(T);
+ return r;
+ }
+ void deallocate(pointer p, size_type n)
+ {
+ if ((char*)(p + n) == ptr_)
+ ptr_ = (char*)p;
+ }
+
+ size_type max_size() const {return N;}
+};
+
+template <class T, std::size_t N>
+inline
+void
+swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {}
+
+#endif // STACK_ALLOCATOR_H
Added: libcxx/trunk/test/std/containers/test_compare.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/test_compare.h?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/test_compare.h (added)
+++ libcxx/trunk/test/std/containers/test_compare.h Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_COMPARE_H
+#define TEST_COMPARE_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+template <class C>
+class test_compare
+ : private C
+{
+ int data_;
+public:
+ explicit test_compare(int data = 0) : data_(data) {}
+
+ typename C::result_type
+ operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
+ typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
+ {return C::operator()(x, y);}
+
+ bool operator==(const test_compare& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_COMPARE_H
Added: libcxx/trunk/test/std/containers/test_hash.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/test_hash.h?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/test_hash.h (added)
+++ libcxx/trunk/test/std/containers/test_hash.h Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_HASH_H
+#define TEST_HASH_H
+
+#include <cstddef>
+#include <type_traits>
+
+template <class C>
+class test_hash
+ : private C
+{
+ int data_;
+public:
+ explicit test_hash(int data = 0) : data_(data) {}
+
+ std::size_t
+ operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
+ {return C::operator()(x);}
+
+ bool operator==(const test_hash& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_HASH_H
Added: libcxx/trunk/test/std/containers/unord/next_prime.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/next_prime.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/next_prime.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/next_prime.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+ switch (n)
+ {
+ case 0:
+ case 1:
+ return false;
+ }
+ for (size_t i = 2; i*i <= n; ++i)
+ {
+ if (n % i == 0)
+ return false;
+ }
+ return true;
+}
+
+int main()
+{
+ assert(std::__next_prime(0) == 0);
+ for (std::size_t n = 1; n <= 100000; ++n)
+ {
+ std::size_t p = std::__next_prime(n);
+ assert(p >= n);
+ for (std::size_t i = n; i < p; ++i)
+ assert(!is_prime(i));
+ assert(is_prime(p));
+ }
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <unordered_map>
+
+struct Key {
+ template <typename T> Key(const T&) {}
+ bool operator== (const Key&) const { return true; }
+};
+
+namespace std
+{
+ template <>
+ struct hash<Key>
+ {
+ size_t operator()(Key const &) const {return 0;}
+ };
+}
+
+int
+main()
+{
+ std::unordered_map<Key, int>::iterator it =
+ std::unordered_map<Key, int>().find(Key(0));
+ std::pair<std::unordered_map<Key, int>::iterator, bool> result =
+ std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/equal_range_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/equal_range_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/equal_range_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/equal_range_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/find_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/find_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/find_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/find_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/find_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/find_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/find_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/find_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_map<int,double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/local_iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/local_iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/local_iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/local_iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,421 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/max_load_factor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/max_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/max_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/max_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_map<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/reserve.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/reserve.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/reserve.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/reserve.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void reserve(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/swap_member.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/types.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// explicit unordered_map(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 4);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,229 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_map<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_map() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == test_hash<std::hash<int> >()));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map& operator=(unordered_map&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map(unordered_map&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ HF hf(42);
+ A a(43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+using namespace std;
+
+struct my_hash
+{
+ size_t operator()(const tuple<int,int>&) const {return 0;}
+};
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ unordered_map<tuple<int,int>, size_t, my_hash> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+ P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+ std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_map<int, int>::iterator i1 = c1.begin();
+ std::unordered_map<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_map<int, int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_map& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_map<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m[i] = i;
+ m2[i] = i;
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(false);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.map/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/version.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/find_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/find_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/find_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/find_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ i->first = 2;
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_multimap<int,double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/load_factor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/load_factor.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/load_factor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ i->first = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,549 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/max_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/max_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/max_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_multimap<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ typedef std::pair<typename C::const_iterator, typename C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ typename C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/reserve.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.find(1)->second == "one");
+ assert(next(c.find(1))->second == "four");
+ assert(c.find(2)->second == "two");
+ assert(next(c.find(2))->second == "four");
+ assert(c.find(3)->second == "three");
+ assert(c.find(4)->second == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/scary.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/scary.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/scary.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/scary.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map class unordered_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+
+#include <unordered_map>
+
+int main()
+{
+ typedef std::unordered_map<int, int> M1;
+ typedef std::unordered_multimap<int, int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/swap_member.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,585 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/types.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ // min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// explicit unordered_multimap(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a+sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 6);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_multimap<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_multimap() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,243 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,228 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
+
+#include <iostream>
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap& operator=(unordered_multimap&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap(unordered_multimap&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ HF hf (43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+}
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp Fri Dec 19 19:40:03 2014
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
Added: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+ {
+ typedef std::unordered_multimap<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ for (int j = 0; j < 2; ++j ) {
+ m.insert (std::make_pair(i,j));
+ m2.insert(std::make_pair(i,j));
+ }
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
More information about the cfe-commits
mailing list