1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
17 #include <unordered_set>
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"
30 typedef std::unordered_set
<NotConstructible
,
31 test_hash
<NotConstructible
>,
32 test_equal_to
<NotConstructible
>,
33 test_allocator
<NotConstructible
>
36 LIBCPP_ASSERT(c
.bucket_count() == 0);
37 assert(c
.hash_function() == test_hash
<NotConstructible
>());
38 assert(c
.key_eq() == test_equal_to
<NotConstructible
>());
39 assert(c
.get_allocator() == (test_allocator
<NotConstructible
>()));
40 assert(c
.size() == 0);
42 assert(std::distance(c
.begin(), c
.end()) == 0);
43 assert(c
.load_factor() == 0);
44 assert(c
.max_load_factor() == 1);
46 #if TEST_STD_VER >= 11
48 typedef std::unordered_set
<NotConstructible
,
49 test_hash
<NotConstructible
>,
50 test_equal_to
<NotConstructible
>,
51 min_allocator
<NotConstructible
>
54 LIBCPP_ASSERT(c
.bucket_count() == 0);
55 assert(c
.hash_function() == test_hash
<NotConstructible
>());
56 assert(c
.key_eq() == test_equal_to
<NotConstructible
>());
57 assert(c
.get_allocator() == (min_allocator
<NotConstructible
>()));
58 assert(c
.size() == 0);
60 assert(std::distance(c
.begin(), c
.end()) == 0);
61 assert(c
.load_factor() == 0);
62 assert(c
.max_load_factor() == 1);
65 typedef explicit_allocator
<NotConstructible
> A
;
66 typedef std::unordered_set
<NotConstructible
,
67 test_hash
<NotConstructible
>,
68 test_equal_to
<NotConstructible
>,
73 LIBCPP_ASSERT(c
.bucket_count() == 0);
74 assert(c
.hash_function() == test_hash
<NotConstructible
>());
75 assert(c
.key_eq() == test_equal_to
<NotConstructible
>());
76 assert(c
.get_allocator() == A());
77 assert(c
.size() == 0);
79 assert(std::distance(c
.begin(), c
.end()) == 0);
80 assert(c
.load_factor() == 0);
81 assert(c
.max_load_factor() == 1);
86 LIBCPP_ASSERT(c
.bucket_count() == 0);
87 assert(c
.hash_function() == test_hash
<NotConstructible
>());
88 assert(c
.key_eq() == test_equal_to
<NotConstructible
>());
89 assert(c
.get_allocator() == a
);
90 assert(c
.size() == 0);
92 assert(std::distance(c
.begin(), c
.end()) == 0);
93 assert(c
.load_factor() == 0);
94 assert(c
.max_load_factor() == 1);
98 std::unordered_set
<int> c
= {};
99 LIBCPP_ASSERT(c
.bucket_count() == 0);
100 assert(c
.size() == 0);
102 assert(std::distance(c
.begin(), c
.end()) == 0);
103 assert(c
.load_factor() == 0);
104 assert(c
.max_load_factor() == 1);