1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <unordered_map>
10 
11 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 //           class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_map
14 
15 // unordered_map(size_type n);
16 
17 #include <unordered_map>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "../../../NotConstructible.h"
22 #include "../../../test_compare.h"
23 #include "../../../test_hash.h"
24 #include "test_allocator.h"
25 #include "min_allocator.h"
26 
main(int,char **)27 int main(int, char**)
28 {
29     {
30         typedef std::unordered_map<NotConstructible, NotConstructible,
31                                    test_hash<std::hash<NotConstructible> >,
32                                    test_compare<std::equal_to<NotConstructible> >,
33                                    test_allocator<std::pair<const NotConstructible,
34                                                                   NotConstructible> >
35                                    > C;
36         C c(7);
37         LIBCPP_ASSERT(c.bucket_count() == 7);
38         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
39         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
40         assert(c.get_allocator() ==
41                (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
42         assert(c.size() == 0);
43         assert(c.empty());
44         assert(std::distance(c.begin(), c.end()) == 0);
45         assert(c.load_factor() == 0);
46         assert(c.max_load_factor() == 1);
47     }
48 #if TEST_STD_VER >= 11
49     {
50         typedef std::unordered_map<NotConstructible, NotConstructible,
51                                    test_hash<std::hash<NotConstructible> >,
52                                    test_compare<std::equal_to<NotConstructible> >,
53                                    min_allocator<std::pair<const NotConstructible,
54                                                                  NotConstructible> >
55                                    > C;
56         C c(7);
57         LIBCPP_ASSERT(c.bucket_count() == 7);
58         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
59         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
60         assert(c.get_allocator() ==
61                (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
62         assert(c.size() == 0);
63         assert(c.empty());
64         assert(std::distance(c.begin(), c.end()) == 0);
65         assert(c.load_factor() == 0);
66         assert(c.max_load_factor() == 1);
67     }
68 #endif
69 
70   return 0;
71 }
72