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>
23 #include "../../../test_compare.h"
24 #include "../../../test_hash.h"
25 #include "test_allocator.h"
26 #include "min_allocator.h"
30 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
32 typedef test_allocator<std::pair<const int, std::string> > A;
33 typedef std::unordered_multimap<int, std::string,
34 test_hash<std::hash<int> >,
35 test_compare<std::equal_to<int> >,
38 typedef std::pair<int, std::string> P;
52 assert(c.bucket_count() >= 7);
53 assert(c.size() == 6);
54 typedef std::pair<C::const_iterator, C::const_iterator> Eq;
55 Eq eq = c.equal_range(1);
56 assert(std::distance(eq.first, eq.second) == 2);
57 C::const_iterator i = eq.first;
58 assert(i->first == 1);
59 assert(i->second == "one");
61 assert(i->first == 1);
62 assert(i->second == "four");
63 eq = c.equal_range(2);
64 assert(std::distance(eq.first, eq.second) == 2);
66 assert(i->first == 2);
67 assert(i->second == "two");
69 assert(i->first == 2);
70 assert(i->second == "four");
72 eq = c.equal_range(3);
73 assert(std::distance(eq.first, eq.second) == 1);
75 assert(i->first == 3);
76 assert(i->second == "three");
77 eq = c.equal_range(4);
78 assert(std::distance(eq.first, eq.second) == 1);
80 assert(i->first == 4);
81 assert(i->second == "four");
82 assert(std::distance(c.begin(), c.end()) == c.size());
83 assert(std::distance(c.cbegin(), c.cend()) == c.size());
84 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
85 assert(c.max_load_factor() == 1);
87 #if __cplusplus >= 201103L
89 typedef min_allocator<std::pair<const int, std::string> > A;
90 typedef std::unordered_multimap<int, std::string,
91 test_hash<std::hash<int> >,
92 test_compare<std::equal_to<int> >,
95 typedef std::pair<int, std::string> P;
109 assert(c.bucket_count() >= 7);
110 assert(c.size() == 6);
111 typedef std::pair<C::const_iterator, C::const_iterator> Eq;
112 Eq eq = c.equal_range(1);
113 assert(std::distance(eq.first, eq.second) == 2);
114 C::const_iterator i = eq.first;
115 assert(i->first == 1);
116 assert(i->second == "one");
118 assert(i->first == 1);
119 assert(i->second == "four");
120 eq = c.equal_range(2);
121 assert(std::distance(eq.first, eq.second) == 2);
123 assert(i->first == 2);
124 assert(i->second == "two");
126 assert(i->first == 2);
127 assert(i->second == "four");
129 eq = c.equal_range(3);
130 assert(std::distance(eq.first, eq.second) == 1);
132 assert(i->first == 3);
133 assert(i->second == "three");
134 eq = c.equal_range(4);
135 assert(std::distance(eq.first, eq.second) == 1);
137 assert(i->first == 4);
138 assert(i->second == "four");
139 assert(std::distance(c.begin(), c.end()) == c.size());
140 assert(std::distance(c.cbegin(), c.cend()) == c.size());
141 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
142 assert(c.max_load_factor() == 1);
145 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS