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_multiset |
14 | |
15 | // iterator begin(); |
16 | // iterator end(); |
17 | // const_iterator begin() const; |
18 | // const_iterator end() const; |
19 | // const_iterator cbegin() const; |
20 | // const_iterator cend() const; |
21 | |
22 | #include <unordered_set> |
23 | #include <cassert> |
24 | #include <cstddef> |
25 | |
26 | #include "test_macros.h" |
27 | #include "min_allocator.h" |
28 | |
29 | int main(int, char**) { |
30 | { |
31 | typedef std::unordered_multiset<int> C; |
32 | typedef int P; |
33 | P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)}; |
34 | C c(a, a + sizeof(a) / sizeof(a[0])); |
35 | assert(c.bucket_count() >= 7); |
36 | assert(c.size() == 6); |
37 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
38 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
39 | C::iterator i; |
40 | } |
41 | { |
42 | typedef std::unordered_multiset<int> C; |
43 | typedef int P; |
44 | P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)}; |
45 | const C c(a, a + sizeof(a) / sizeof(a[0])); |
46 | assert(c.bucket_count() >= 7); |
47 | assert(c.size() == 6); |
48 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
49 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
50 | C::const_iterator i; |
51 | } |
52 | #if TEST_STD_VER >= 11 |
53 | { |
54 | typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
55 | typedef int P; |
56 | P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)}; |
57 | C c(a, a + sizeof(a) / sizeof(a[0])); |
58 | assert(c.bucket_count() >= 7); |
59 | assert(c.size() == 6); |
60 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
61 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
62 | C::iterator i; |
63 | } |
64 | { |
65 | typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
66 | typedef int P; |
67 | P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)}; |
68 | const C c(a, a + sizeof(a) / sizeof(a[0])); |
69 | assert(c.bucket_count() >= 7); |
70 | assert(c.size() == 6); |
71 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
72 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
73 | C::const_iterator i; |
74 | } |
75 | #endif |
76 | #if TEST_STD_VER > 11 |
77 | { // N3644 testing |
78 | typedef std::unordered_multiset<int> C; |
79 | C::iterator ii1{}, ii2{}; |
80 | C::iterator ii4 = ii1; |
81 | C::const_iterator cii{}; |
82 | assert(ii1 == ii2); |
83 | assert(ii1 == ii4); |
84 | |
85 | assert(!(ii1 != ii2)); |
86 | |
87 | assert((ii1 == cii)); |
88 | assert((cii == ii1)); |
89 | assert(!(ii1 != cii)); |
90 | assert(!(cii != ii1)); |
91 | } |
92 | #endif |
93 | |
94 | return 0; |
95 | } |
96 | |