]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / containers / unord / unord.multimap / unord.multimap.swap / swap_non_member.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <unordered_map>
11
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
15
16 // void swap(unordered_multimap& __u);
17
18 #include <unordered_map>
19 #include <string>
20 #include <cassert>
21 #include <cstddef>
22
23 #include "test_macros.h"
24 #include "../../../test_compare.h"
25 #include "../../../test_hash.h"
26 #include "test_allocator.h"
27 #include "min_allocator.h"
28
29 int main()
30 {
31     {
32         typedef test_hash<std::hash<int> > Hash;
33         typedef test_compare<std::equal_to<int> > Compare;
34         typedef test_allocator<std::pair<const int, std::string> > Alloc;
35         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
36         C c1(0, Hash(1), Compare(1), Alloc(1, 1));
37         C c2(0, Hash(2), Compare(2), Alloc(1, 2));
38         c2.max_load_factor(2);
39         swap(c1, c2);
40
41         LIBCPP_ASSERT(c1.bucket_count() == 0);
42         assert(c1.size() == 0);
43         assert(c1.hash_function() == Hash(2));
44         assert(c1.key_eq() == Compare(2));
45         assert(c1.get_allocator().get_id() == 1);
46         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
47         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
48         assert(c1.max_load_factor() == 2);
49
50         LIBCPP_ASSERT(c2.bucket_count() == 0);
51         assert(c2.size() == 0);
52         assert(c2.hash_function() == Hash(1));
53         assert(c2.key_eq() == Compare(1));
54         assert(c2.get_allocator().get_id() == 2);
55         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
56         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
57         assert(c2.max_load_factor() == 1);
58     }
59     {
60         typedef test_hash<std::hash<int> > Hash;
61         typedef test_compare<std::equal_to<int> > Compare;
62         typedef test_allocator<std::pair<const int, std::string> > Alloc;
63         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
64         typedef std::pair<int, std::string> P;
65         P a2[] =
66         {
67             P(10, "ten"),
68             P(20, "twenty"),
69             P(30, "thirty"),
70             P(40, "forty"),
71             P(50, "fifty"),
72             P(60, "sixty"),
73             P(70, "seventy"),
74             P(80, "eighty"),
75         };
76         C c1(0, Hash(1), Compare(1), Alloc(1, 1));
77         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(1, 2));
78         c2.max_load_factor(2);
79         swap(c1, c2);
80
81         assert(c1.bucket_count() >= 8);
82         assert(c1.size() == 8);
83         assert(c1.find(10)->second == "ten");
84         assert(c1.find(20)->second == "twenty");
85         assert(c1.find(30)->second == "thirty");
86         assert(c1.find(40)->second == "forty");
87         assert(c1.find(50)->second == "fifty");
88         assert(c1.find(60)->second == "sixty");
89         assert(c1.find(70)->second == "seventy");
90         assert(c1.find(80)->second == "eighty");
91         assert(c1.hash_function() == Hash(2));
92         assert(c1.key_eq() == Compare(2));
93         assert(c1.get_allocator().get_id() == 1);
94         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
95         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
96         assert(c1.max_load_factor() == 2);
97
98         LIBCPP_ASSERT(c2.bucket_count() == 0);
99         assert(c2.size() == 0);
100         assert(c2.hash_function() == Hash(1));
101         assert(c2.key_eq() == Compare(1));
102         assert(c2.get_allocator().get_id() == 2);
103         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
104         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
105         assert(c2.max_load_factor() == 1);
106     }
107     {
108         typedef test_hash<std::hash<int> > Hash;
109         typedef test_compare<std::equal_to<int> > Compare;
110         typedef test_allocator<std::pair<const int, std::string> > Alloc;
111         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
112         typedef std::pair<int, std::string> P;
113         P a1[] =
114         {
115             P(1, "one"),
116             P(2, "two"),
117             P(3, "three"),
118             P(4, "four"),
119             P(1, "four"),
120             P(2, "four"),
121         };
122         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1, 1));
123         C c2(0, Hash(2), Compare(2), Alloc(1, 2));
124         c2.max_load_factor(2);
125         swap(c1, c2);
126
127         LIBCPP_ASSERT(c1.bucket_count() == 0);
128         assert(c1.size() == 0);
129         assert(c1.hash_function() == Hash(2));
130         assert(c1.key_eq() == Compare(2));
131         assert(c1.get_allocator().get_id() == 1);
132         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
133         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
134         assert(c1.max_load_factor() == 2);
135
136         assert(c2.bucket_count() >= 6);
137         assert(c2.size() == 6);
138         assert(c2.find(1)->second == "one");
139         assert(next(c2.find(1))->second == "four");
140         assert(c2.find(2)->second == "two");
141         assert(next(c2.find(2))->second == "four");
142         assert(c2.find(3)->second == "three");
143         assert(c2.find(4)->second == "four");
144         assert(c2.hash_function() == Hash(1));
145         assert(c2.key_eq() == Compare(1));
146         assert(c2.get_allocator().get_id() == 2);
147         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
148         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
149         assert(c2.max_load_factor() == 1);
150     }
151     {
152         typedef test_hash<std::hash<int> > Hash;
153         typedef test_compare<std::equal_to<int> > Compare;
154         typedef test_allocator<std::pair<const int, std::string> > Alloc;
155         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
156         typedef std::pair<int, std::string> P;
157         P a1[] =
158         {
159             P(1, "one"),
160             P(2, "two"),
161             P(3, "three"),
162             P(4, "four"),
163             P(1, "four"),
164             P(2, "four"),
165         };
166         P a2[] =
167         {
168             P(10, "ten"),
169             P(20, "twenty"),
170             P(30, "thirty"),
171             P(40, "forty"),
172             P(50, "fifty"),
173             P(60, "sixty"),
174             P(70, "seventy"),
175             P(80, "eighty"),
176         };
177         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1, 1));
178         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(1, 2));
179         c2.max_load_factor(2);
180         swap(c1, c2);
181
182         assert(c1.bucket_count() >= 8);
183         assert(c1.size() == 8);
184         assert(c1.find(10)->second == "ten");
185         assert(c1.find(20)->second == "twenty");
186         assert(c1.find(30)->second == "thirty");
187         assert(c1.find(40)->second == "forty");
188         assert(c1.find(50)->second == "fifty");
189         assert(c1.find(60)->second == "sixty");
190         assert(c1.find(70)->second == "seventy");
191         assert(c1.find(80)->second == "eighty");
192         assert(c1.hash_function() == Hash(2));
193         assert(c1.key_eq() == Compare(2));
194         assert(c1.get_allocator().get_id() == 1);
195         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
196         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
197         assert(c1.max_load_factor() == 2);
198
199         assert(c2.bucket_count() >= 6);
200         assert(c2.size() == 6);
201         assert(c2.find(1)->second == "one");
202         assert(next(c2.find(1))->second == "four");
203         assert(c2.find(2)->second == "two");
204         assert(next(c2.find(2))->second == "four");
205         assert(c2.find(3)->second == "three");
206         assert(c2.find(4)->second == "four");
207         assert(c2.hash_function() == Hash(1));
208         assert(c2.key_eq() == Compare(1));
209         assert(c2.get_allocator().get_id() == 2);
210         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
211         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
212         assert(c2.max_load_factor() == 1);
213     }
214
215     {
216         typedef test_hash<std::hash<int> > Hash;
217         typedef test_compare<std::equal_to<int> > Compare;
218         typedef other_allocator<std::pair<const int, std::string> > Alloc;
219         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
220         C c1(0, Hash(1), Compare(1), Alloc(1));
221         C c2(0, Hash(2), Compare(2), Alloc(2));
222         c2.max_load_factor(2);
223         swap(c1, c2);
224
225         LIBCPP_ASSERT(c1.bucket_count() == 0);
226         assert(c1.size() == 0);
227         assert(c1.hash_function() == Hash(2));
228         assert(c1.key_eq() == Compare(2));
229         assert(c1.get_allocator() == Alloc(2));
230         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
231         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
232         assert(c1.max_load_factor() == 2);
233
234         LIBCPP_ASSERT(c2.bucket_count() == 0);
235         assert(c2.size() == 0);
236         assert(c2.hash_function() == Hash(1));
237         assert(c2.key_eq() == Compare(1));
238         assert(c2.get_allocator() == Alloc(1));
239         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
240         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
241         assert(c2.max_load_factor() == 1);
242     }
243     {
244         typedef test_hash<std::hash<int> > Hash;
245         typedef test_compare<std::equal_to<int> > Compare;
246         typedef other_allocator<std::pair<const int, std::string> > Alloc;
247         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
248         typedef std::pair<int, std::string> P;
249         P a2[] =
250         {
251             P(10, "ten"),
252             P(20, "twenty"),
253             P(30, "thirty"),
254             P(40, "forty"),
255             P(50, "fifty"),
256             P(60, "sixty"),
257             P(70, "seventy"),
258             P(80, "eighty"),
259         };
260         C c1(0, Hash(1), Compare(1), Alloc(1));
261         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
262         c2.max_load_factor(2);
263         swap(c1, c2);
264
265         assert(c1.bucket_count() >= 8);
266         assert(c1.size() == 8);
267         assert(c1.find(10)->second == "ten");
268         assert(c1.find(20)->second == "twenty");
269         assert(c1.find(30)->second == "thirty");
270         assert(c1.find(40)->second == "forty");
271         assert(c1.find(50)->second == "fifty");
272         assert(c1.find(60)->second == "sixty");
273         assert(c1.find(70)->second == "seventy");
274         assert(c1.find(80)->second == "eighty");
275         assert(c1.hash_function() == Hash(2));
276         assert(c1.key_eq() == Compare(2));
277         assert(c1.get_allocator() == Alloc(2));
278         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
279         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
280         assert(c1.max_load_factor() == 2);
281
282         LIBCPP_ASSERT(c2.bucket_count() == 0);
283         assert(c2.size() == 0);
284         assert(c2.hash_function() == Hash(1));
285         assert(c2.key_eq() == Compare(1));
286         assert(c2.get_allocator() == Alloc(1));
287         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
288         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
289         assert(c2.max_load_factor() == 1);
290     }
291     {
292         typedef test_hash<std::hash<int> > Hash;
293         typedef test_compare<std::equal_to<int> > Compare;
294         typedef other_allocator<std::pair<const int, std::string> > Alloc;
295         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
296         typedef std::pair<int, std::string> P;
297         P a1[] =
298         {
299             P(1, "one"),
300             P(2, "two"),
301             P(3, "three"),
302             P(4, "four"),
303             P(1, "four"),
304             P(2, "four"),
305         };
306         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
307         C c2(0, Hash(2), Compare(2), Alloc(2));
308         c2.max_load_factor(2);
309         swap(c1, c2);
310
311         LIBCPP_ASSERT(c1.bucket_count() == 0);
312         assert(c1.size() == 0);
313         assert(c1.hash_function() == Hash(2));
314         assert(c1.key_eq() == Compare(2));
315         assert(c1.get_allocator() == Alloc(2));
316         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
317         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
318         assert(c1.max_load_factor() == 2);
319
320         assert(c2.bucket_count() >= 6);
321         assert(c2.size() == 6);
322         assert(c2.find(1)->second == "one");
323         assert(next(c2.find(1))->second == "four");
324         assert(c2.find(2)->second == "two");
325         assert(next(c2.find(2))->second == "four");
326         assert(c2.find(3)->second == "three");
327         assert(c2.find(4)->second == "four");
328         assert(c2.hash_function() == Hash(1));
329         assert(c2.key_eq() == Compare(1));
330         assert(c2.get_allocator() == Alloc(1));
331         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
332         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
333         assert(c2.max_load_factor() == 1);
334     }
335     {
336         typedef test_hash<std::hash<int> > Hash;
337         typedef test_compare<std::equal_to<int> > Compare;
338         typedef other_allocator<std::pair<const int, std::string> > Alloc;
339         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
340         typedef std::pair<int, std::string> P;
341         P a1[] =
342         {
343             P(1, "one"),
344             P(2, "two"),
345             P(3, "three"),
346             P(4, "four"),
347             P(1, "four"),
348             P(2, "four"),
349         };
350         P a2[] =
351         {
352             P(10, "ten"),
353             P(20, "twenty"),
354             P(30, "thirty"),
355             P(40, "forty"),
356             P(50, "fifty"),
357             P(60, "sixty"),
358             P(70, "seventy"),
359             P(80, "eighty"),
360         };
361         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
362         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
363         c2.max_load_factor(2);
364         swap(c1, c2);
365
366         assert(c1.bucket_count() >= 8);
367         assert(c1.size() == 8);
368         assert(c1.find(10)->second == "ten");
369         assert(c1.find(20)->second == "twenty");
370         assert(c1.find(30)->second == "thirty");
371         assert(c1.find(40)->second == "forty");
372         assert(c1.find(50)->second == "fifty");
373         assert(c1.find(60)->second == "sixty");
374         assert(c1.find(70)->second == "seventy");
375         assert(c1.find(80)->second == "eighty");
376         assert(c1.hash_function() == Hash(2));
377         assert(c1.key_eq() == Compare(2));
378         assert(c1.get_allocator() == Alloc(2));
379         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
380         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
381         assert(c1.max_load_factor() == 2);
382
383         assert(c2.bucket_count() >= 6);
384         assert(c2.size() == 6);
385         assert(c2.find(1)->second == "one");
386         assert(next(c2.find(1))->second == "four");
387         assert(c2.find(2)->second == "two");
388         assert(next(c2.find(2))->second == "four");
389         assert(c2.find(3)->second == "three");
390         assert(c2.find(4)->second == "four");
391         assert(c2.hash_function() == Hash(1));
392         assert(c2.key_eq() == Compare(1));
393         assert(c2.get_allocator() == Alloc(1));
394         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
395         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
396         assert(c2.max_load_factor() == 1);
397     }
398 #if TEST_STD_VER >= 11
399     {
400         typedef test_hash<std::hash<int> > Hash;
401         typedef test_compare<std::equal_to<int> > Compare;
402         typedef min_allocator<std::pair<const int, std::string> > Alloc;
403         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
404         C c1(0, Hash(1), Compare(1), Alloc());
405         C c2(0, Hash(2), Compare(2), Alloc());
406         c2.max_load_factor(2);
407         swap(c1, c2);
408
409         LIBCPP_ASSERT(c1.bucket_count() == 0);
410         assert(c1.size() == 0);
411         assert(c1.hash_function() == Hash(2));
412         assert(c1.key_eq() == Compare(2));
413         assert(c1.get_allocator() == Alloc());
414         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
415         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
416         assert(c1.max_load_factor() == 2);
417
418         LIBCPP_ASSERT(c2.bucket_count() == 0);
419         assert(c2.size() == 0);
420         assert(c2.hash_function() == Hash(1));
421         assert(c2.key_eq() == Compare(1));
422         assert(c2.get_allocator() == Alloc());
423         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
424         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
425         assert(c2.max_load_factor() == 1);
426     }
427     {
428         typedef test_hash<std::hash<int> > Hash;
429         typedef test_compare<std::equal_to<int> > Compare;
430         typedef min_allocator<std::pair<const int, std::string> > Alloc;
431         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
432         typedef std::pair<int, std::string> P;
433         P a2[] =
434         {
435             P(10, "ten"),
436             P(20, "twenty"),
437             P(30, "thirty"),
438             P(40, "forty"),
439             P(50, "fifty"),
440             P(60, "sixty"),
441             P(70, "seventy"),
442             P(80, "eighty"),
443         };
444         C c1(0, Hash(1), Compare(1), Alloc());
445         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
446         c2.max_load_factor(2);
447         swap(c1, c2);
448
449         assert(c1.bucket_count() >= 8);
450         assert(c1.size() == 8);
451         assert(c1.find(10)->second == "ten");
452         assert(c1.find(20)->second == "twenty");
453         assert(c1.find(30)->second == "thirty");
454         assert(c1.find(40)->second == "forty");
455         assert(c1.find(50)->second == "fifty");
456         assert(c1.find(60)->second == "sixty");
457         assert(c1.find(70)->second == "seventy");
458         assert(c1.find(80)->second == "eighty");
459         assert(c1.hash_function() == Hash(2));
460         assert(c1.key_eq() == Compare(2));
461         assert(c1.get_allocator() == Alloc());
462         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
463         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
464         assert(c1.max_load_factor() == 2);
465
466         LIBCPP_ASSERT(c2.bucket_count() == 0);
467         assert(c2.size() == 0);
468         assert(c2.hash_function() == Hash(1));
469         assert(c2.key_eq() == Compare(1));
470         assert(c2.get_allocator() == Alloc());
471         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
472         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
473         assert(c2.max_load_factor() == 1);
474     }
475     {
476         typedef test_hash<std::hash<int> > Hash;
477         typedef test_compare<std::equal_to<int> > Compare;
478         typedef min_allocator<std::pair<const int, std::string> > Alloc;
479         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
480         typedef std::pair<int, std::string> P;
481         P a1[] =
482         {
483             P(1, "one"),
484             P(2, "two"),
485             P(3, "three"),
486             P(4, "four"),
487             P(1, "four"),
488             P(2, "four"),
489         };
490         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
491         C c2(0, Hash(2), Compare(2), Alloc());
492         c2.max_load_factor(2);
493         swap(c1, c2);
494
495         LIBCPP_ASSERT(c1.bucket_count() == 0);
496         assert(c1.size() == 0);
497         assert(c1.hash_function() == Hash(2));
498         assert(c1.key_eq() == Compare(2));
499         assert(c1.get_allocator() == Alloc());
500         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
501         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
502         assert(c1.max_load_factor() == 2);
503
504         assert(c2.bucket_count() >= 6);
505         assert(c2.size() == 6);
506         assert(c2.find(1)->second == "one");
507         assert(next(c2.find(1))->second == "four");
508         assert(c2.find(2)->second == "two");
509         assert(next(c2.find(2))->second == "four");
510         assert(c2.find(3)->second == "three");
511         assert(c2.find(4)->second == "four");
512         assert(c2.hash_function() == Hash(1));
513         assert(c2.key_eq() == Compare(1));
514         assert(c2.get_allocator() == Alloc());
515         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
516         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
517         assert(c2.max_load_factor() == 1);
518     }
519     {
520         typedef test_hash<std::hash<int> > Hash;
521         typedef test_compare<std::equal_to<int> > Compare;
522         typedef min_allocator<std::pair<const int, std::string> > Alloc;
523         typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
524         typedef std::pair<int, std::string> P;
525         P a1[] =
526         {
527             P(1, "one"),
528             P(2, "two"),
529             P(3, "three"),
530             P(4, "four"),
531             P(1, "four"),
532             P(2, "four"),
533         };
534         P a2[] =
535         {
536             P(10, "ten"),
537             P(20, "twenty"),
538             P(30, "thirty"),
539             P(40, "forty"),
540             P(50, "fifty"),
541             P(60, "sixty"),
542             P(70, "seventy"),
543             P(80, "eighty"),
544         };
545         C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
546         C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
547         c2.max_load_factor(2);
548         swap(c1, c2);
549
550         assert(c1.bucket_count() >= 8);
551         assert(c1.size() == 8);
552         assert(c1.find(10)->second == "ten");
553         assert(c1.find(20)->second == "twenty");
554         assert(c1.find(30)->second == "thirty");
555         assert(c1.find(40)->second == "forty");
556         assert(c1.find(50)->second == "fifty");
557         assert(c1.find(60)->second == "sixty");
558         assert(c1.find(70)->second == "seventy");
559         assert(c1.find(80)->second == "eighty");
560         assert(c1.hash_function() == Hash(2));
561         assert(c1.key_eq() == Compare(2));
562         assert(c1.get_allocator() == Alloc());
563         assert(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
564         assert(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
565         assert(c1.max_load_factor() == 2);
566
567         assert(c2.bucket_count() >= 6);
568         assert(c2.size() == 6);
569         assert(c2.find(1)->second == "one");
570         assert(next(c2.find(1))->second == "four");
571         assert(c2.find(2)->second == "two");
572         assert(next(c2.find(2))->second == "four");
573         assert(c2.find(3)->second == "three");
574         assert(c2.find(4)->second == "four");
575         assert(c2.hash_function() == Hash(1));
576         assert(c2.key_eq() == Compare(1));
577         assert(c2.get_allocator() == Alloc());
578         assert(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
579         assert(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
580         assert(c2.max_load_factor() == 1);
581     }
582 #endif
583 }