]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / containers / unord / unord.multimap / unord.multimap.cnstr / size_hash_equal.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 // unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
17
18 #include <unordered_map>
19 #include <cassert>
20
21 #include "test_macros.h"
22 #include "../../../NotConstructible.h"
23 #include "../../../test_compare.h"
24 #include "../../../test_hash.h"
25 #include "test_allocator.h"
26 #include "min_allocator.h"
27
28 int main()
29 {
30     {
31         typedef std::unordered_multimap<NotConstructible, NotConstructible,
32                                    test_hash<std::hash<NotConstructible> >,
33                                    test_compare<std::equal_to<NotConstructible> >,
34                                    test_allocator<std::pair<const NotConstructible,
35                                                                   NotConstructible> >
36                                    > C;
37         C c(7,
38             test_hash<std::hash<NotConstructible> >(8),
39             test_compare<std::equal_to<NotConstructible> >(9)
40            );
41         LIBCPP_ASSERT(c.bucket_count() == 7);
42         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
43         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
44         assert(c.get_allocator() ==
45                (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
46         assert(c.size() == 0);
47         assert(c.empty());
48         assert(std::distance(c.begin(), c.end()) == 0);
49         assert(c.load_factor() == 0);
50         assert(c.max_load_factor() == 1);
51     }
52 #if TEST_STD_VER >= 11
53     {
54         typedef std::unordered_multimap<NotConstructible, NotConstructible,
55                                    test_hash<std::hash<NotConstructible> >,
56                                    test_compare<std::equal_to<NotConstructible> >,
57                                    min_allocator<std::pair<const NotConstructible,
58                                                                  NotConstructible> >
59                                    > C;
60         C c(7,
61             test_hash<std::hash<NotConstructible> >(8),
62             test_compare<std::equal_to<NotConstructible> >(9)
63            );
64         LIBCPP_ASSERT(c.bucket_count() == 7);
65         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
66         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
67         assert(c.get_allocator() ==
68                (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
69         assert(c.size() == 0);
70         assert(c.empty());
71         assert(std::distance(c.begin(), c.end()) == 0);
72         assert(c.load_factor() == 0);
73         assert(c.max_load_factor() == 1);
74     }
75 #endif
76 }