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_multimap
14
15 // size_type bucket(const key_type& __k) const;
16
17 #include <unordered_map>
18 #include <string>
19 #include <cassert>
20
21 #include "test_macros.h"
22 #include "min_allocator.h"
23
main(int,char **)24 int main(int, char**)
25 {
26 {
27 typedef std::unordered_multimap<int, std::string> C;
28 typedef std::pair<int, std::string> P;
29 P a[] =
30 {
31 P(1, "one"),
32 P(2, "two"),
33 P(3, "three"),
34 P(4, "four"),
35 P(1, "four"),
36 P(2, "four"),
37 };
38 const C c(std::begin(a), std::end(a));
39 size_t bc = c.bucket_count();
40 assert(bc >= 7);
41 for (size_t i = 0; i < 13; ++i)
42 LIBCPP_ASSERT(c.bucket(i) == i % bc);
43 }
44 #if TEST_STD_VER >= 11
45 {
46 typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
47 min_allocator<std::pair<const int, std::string>>> C;
48 typedef std::pair<int, std::string> P;
49 P a[] =
50 {
51 P(1, "one"),
52 P(2, "two"),
53 P(3, "three"),
54 P(4, "four"),
55 P(1, "four"),
56 P(2, "four"),
57 };
58 const C c(std::begin(a), std::end(a));
59 size_t bc = c.bucket_count();
60 assert(bc >= 7);
61 for (size_t i = 0; i < 13; ++i)
62 LIBCPP_ASSERT(c.bucket(i) == i % bc);
63 }
64 #endif
65
66 return 0;
67 }
68