aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/associative
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/associative')
-rw-r--r--test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp76
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp85
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp64
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp76
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp78
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp64
-rw-r--r--test/std/containers/associative/multiset/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/associative/multiset/extract_key.pass.cpp71
-rw-r--r--test/std/containers/associative/multiset/insert_node_type.pass.cpp77
-rw-r--r--test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp59
-rw-r--r--test/std/containers/associative/set/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/associative/set/extract_key.pass.cpp71
-rw-r--r--test/std/containers/associative/set/insert_node_type.pass.cpp83
-rw-r--r--test/std/containers/associative/set/insert_node_type_hint.pass.cpp61
16 files changed, 1119 insertions, 0 deletions
diff --git a/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp b/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..ea7fd890764b
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// node_type extract(const_iterator);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::map<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::map<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp b/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..41cd09300b2a
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// node_type extract(key_type const&);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::map<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::map<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..cc1704c30873
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// insert_return_type insert(node_type&&);
+
+#include <map>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position->first == i && irt.position->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.key() == 0 && irt.node.mapped() == 42);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::map<int, int> m;
+ test(m);
+ std::map<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..3c6b3e31af46
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::map<int, int> m;
+ test(m);
+ std::map<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..3e00d2b98d70
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// node_type extract(const_iterator);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::multimap<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::multimap<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..ca69cca6b0ec
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// node_type extract(key_type const&);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::multimap<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::multimap<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..906770514196
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// iterator insert(node_type&&);
+
+#include <map>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto it = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(it != c.end());
+ assert(it->second == 42);
+ }
+
+ assert(c.size() == 11);
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::multimap<int, int> m;
+ test(m);
+ std::multimap<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..82e7d80c06e6
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it == c.find(i));
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::multimap<int, int> m;
+ test(m);
+ std::multimap<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multiset/extract_iterator.pass.cpp b/test/std/containers/associative/multiset/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..0f41169e9fe0
--- /dev/null
+++ b/test/std/containers/associative/multiset/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// node_type extract(const_iterator);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::multiset<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::multiset<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/multiset/extract_key.pass.cpp b/test/std/containers/associative/multiset/extract_key.pass.cpp
new file mode 100644
index 000000000000..9ad0184100b6
--- /dev/null
+++ b/test/std/containers/associative/multiset/extract_key.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// node_type extract(key_type const&);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::multiset<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::multiset<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/multiset/insert_node_type.pass.cpp b/test/std/containers/associative/multiset/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..ca51ec9f0930
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_node_type.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// iterator insert(node_type&&);
+
+#include <set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ assert(*it == i);
+ assert(node.empty());
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto it = c.insert(std::move(dupl));
+ assert(*it == 0);
+ }
+
+ assert(c.size() == 11);
+
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::multiset<int> m;
+ test(m);
+ std::multiset<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp b/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..9d0af0653f6c
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::multiset<int> m;
+ test(m);
+ std::multiset<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/set/extract_iterator.pass.cpp b/test/std/containers/associative/set/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..ffcf71486883
--- /dev/null
+++ b/test/std/containers/associative/set/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// node_type extract(const_iterator);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::set<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/set/extract_key.pass.cpp b/test/std/containers/associative/set/extract_key.pass.cpp
new file mode 100644
index 000000000000..1fb7ab9116eb
--- /dev/null
+++ b/test/std/containers/associative/set/extract_key.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// node_type extract(key_type const&);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::set<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/set/insert_node_type.pass.cpp b/test/std/containers/associative/set/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..4186f20e771f
--- /dev/null
+++ b/test/std/containers/associative/set/insert_node_type.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// insert_return_type insert(node_type&&);
+
+#include <set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(*irt.position == i);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.value() == 0);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::set<int> m;
+ test(m);
+ std::set<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/set/insert_node_type_hint.pass.cpp b/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..761ceef6a4a1
--- /dev/null
+++ b/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::set<int> m;
+ test(m);
+ std::set<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}