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_set>
10 
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 //           class Alloc = allocator<Value>>
13 // class unordered_set
14 
15 // unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
16 
17 #include <unordered_set>
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_set<NotConstructible,
31                                    test_hash<NotConstructible>,
32                                    test_equal_to<NotConstructible>,
33                                    test_allocator<NotConstructible>
34                                    > C;
35         C c(7,
36             test_hash<NotConstructible>(8),
37             test_equal_to<NotConstructible>(9),
38             test_allocator<NotConstructible>(10)
39            );
40         LIBCPP_ASSERT(c.bucket_count() == 7);
41         assert(c.hash_function() == test_hash<NotConstructible>(8));
42         assert(c.key_eq() == test_equal_to<NotConstructible>(9));
43         assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
44         assert(c.size() == 0);
45         assert(c.empty());
46         assert(std::distance(c.begin(), c.end()) == 0);
47         assert(c.load_factor() == 0);
48         assert(c.max_load_factor() == 1);
49     }
50 #if TEST_STD_VER >= 11
51     {
52         typedef std::unordered_set<NotConstructible,
53                                    test_hash<NotConstructible>,
54                                    test_equal_to<NotConstructible>,
55                                    min_allocator<NotConstructible>
56                                    > C;
57         C c(7,
58             test_hash<NotConstructible>(8),
59             test_equal_to<NotConstructible>(9),
60             min_allocator<NotConstructible>()
61            );
62         LIBCPP_ASSERT(c.bucket_count() == 7);
63         assert(c.hash_function() == test_hash<NotConstructible>(8));
64         assert(c.key_eq() == test_equal_to<NotConstructible>(9));
65         assert(c.get_allocator() == (min_allocator<NotConstructible>()));
66         assert(c.size() == 0);
67         assert(c.empty());
68         assert(std::distance(c.begin(), c.end()) == 0);
69         assert(c.load_factor() == 0);
70         assert(c.max_load_factor() == 1);
71     }
72 #endif
73 
74   return 0;
75 }
76