1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
13 // class Alloc = allocator<pair<const Key, T>>>
14 // class unordered_multimap
16 // unordered_multimap& operator=(initializer_list<value_type> il);
18 #include <unordered_map>
24 #include "../../../test_compare.h"
25 #include "../../../test_hash.h"
26 #include "test_allocator.h"
27 #include "min_allocator.h"
31 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
33 typedef test_allocator<std::pair<const int, std::string> > A;
34 typedef std::unordered_multimap<int, std::string,
35 test_hash<std::hash<int> >,
36 test_compare<std::equal_to<int> >,
39 typedef std::pair<int, std::string> P;
53 assert(c.bucket_count() >= 7);
54 assert(c.size() == 6);
55 typedef std::pair<C::const_iterator, C::const_iterator> Eq;
56 Eq eq = c.equal_range(1);
57 assert(std::distance(eq.first, eq.second) == 2);
58 C::const_iterator i = eq.first;
59 assert(i->first == 1);
60 assert(i->second == "one");
62 assert(i->first == 1);
63 assert(i->second == "four");
64 eq = c.equal_range(2);
65 assert(std::distance(eq.first, eq.second) == 2);
67 assert(i->first == 2);
68 assert(i->second == "two");
70 assert(i->first == 2);
71 assert(i->second == "four");
73 eq = c.equal_range(3);
74 assert(std::distance(eq.first, eq.second) == 1);
76 assert(i->first == 3);
77 assert(i->second == "three");
78 eq = c.equal_range(4);
79 assert(std::distance(eq.first, eq.second) == 1);
81 assert(i->first == 4);
82 assert(i->second == "four");
83 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
84 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
85 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
86 assert(c.max_load_factor() == 1);
88 #if TEST_STD_VER >= 11
90 typedef min_allocator<std::pair<const int, std::string> > A;
91 typedef std::unordered_multimap<int, std::string,
92 test_hash<std::hash<int> >,
93 test_compare<std::equal_to<int> >,
96 typedef std::pair<int, std::string> P;
110 assert(c.bucket_count() >= 7);
111 assert(c.size() == 6);
112 typedef std::pair<C::const_iterator, C::const_iterator> Eq;
113 Eq eq = c.equal_range(1);
114 assert(std::distance(eq.first, eq.second) == 2);
115 C::const_iterator i = eq.first;
116 assert(i->first == 1);
117 assert(i->second == "one");
119 assert(i->first == 1);
120 assert(i->second == "four");
121 eq = c.equal_range(2);
122 assert(std::distance(eq.first, eq.second) == 2);
124 assert(i->first == 2);
125 assert(i->second == "two");
127 assert(i->first == 2);
128 assert(i->second == "four");
130 eq = c.equal_range(3);
131 assert(std::distance(eq.first, eq.second) == 1);
133 assert(i->first == 3);
134 assert(i->second == "three");
135 eq = c.equal_range(4);
136 assert(std::distance(eq.first, eq.second) == 1);
138 assert(i->first == 4);
139 assert(i->second == "four");
140 assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
141 assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
142 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
143 assert(c.max_load_factor() == 1);
146 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS