Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / bucket.pass.cpp
blob969c3f6b93e74dea8104a2ae7f1a960f58f6205c
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 //===----------------------------------------------------------------------===//
9 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // size_type bucket(const key_type& __k) const;
17 #include <unordered_set>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "min_allocator.h"
23 int main(int, char**)
26 typedef std::unordered_set<int> C;
27 typedef int P;
28 P a[] =
30 P(1),
31 P(2),
32 P(3),
33 P(4),
34 P(1),
35 P(2)
37 const C c(std::begin(a), std::end(a));
38 std::size_t bc = c.bucket_count();
39 assert(bc >= 5);
40 for (std::size_t i = 0; i < 13; ++i)
41 LIBCPP_ASSERT(c.bucket(i) == i % bc);
43 #if TEST_STD_VER >= 11
45 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
46 typedef int P;
47 P a[] =
49 P(1),
50 P(2),
51 P(3),
52 P(4),
53 P(1),
54 P(2)
56 const C c(std::begin(a), std::end(a));
57 std::size_t bc = c.bucket_count();
58 assert(bc >= 5);
59 for (std::size_t i = 0; i < 13; ++i)
60 LIBCPP_ASSERT(c.bucket(i) == i % bc);
62 #endif
64 return 0;