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_multiset
15 // void rehash(size_type n);
17 #include <unordered_set>
20 #include "test_macros.h"
21 #include "min_allocator.h"
24 void rehash_postcondition(const C
& c
, std::size_t n
)
26 assert(c
.bucket_count() >= c
.size() / c
.max_load_factor() && c
.bucket_count() >= n
);
32 assert(c
.size() == 6);
33 assert(c
.count(1) == 2);
34 assert(c
.count(2) == 2);
35 assert(c
.count(3) == 1);
36 assert(c
.count(4) == 1);
42 typedef std::unordered_multiset
<int> C
;
53 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
55 assert(c
.bucket_count() >= 7);
57 rehash_postcondition(c
, 3);
58 LIBCPP_ASSERT(c
.bucket_count() == 7);
62 rehash_postcondition(c
, 3);
63 LIBCPP_ASSERT(c
.bucket_count() == 3);
66 rehash_postcondition(c
, 31);
67 LIBCPP_ASSERT(c
.bucket_count() == 31);
70 #if TEST_STD_VER >= 11
72 typedef std::unordered_multiset
<int, std::hash
<int>,
73 std::equal_to
<int>, min_allocator
<int>> C
;
84 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
86 assert(c
.bucket_count() >= 7);
88 rehash_postcondition(c
, 3);
89 LIBCPP_ASSERT(c
.bucket_count() == 7);
93 rehash_postcondition(c
, 3);
94 LIBCPP_ASSERT(c
.bucket_count() == 3);
97 rehash_postcondition(c
, 31);
98 LIBCPP_ASSERT(c
.bucket_count() == 31);