[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / multiset / iterator.pass.cpp
blob27a8dbf1a0388ed3305bbd57337b6f33428c5385
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 // <set>
11 // class multiset
13 // iterator begin();
14 // const_iterator begin() const;
15 // iterator end();
16 // const_iterator end() const;
18 // reverse_iterator rbegin();
19 // const_reverse_iterator rbegin() const;
20 // reverse_iterator rend();
21 // const_reverse_iterator rend() const;
23 // const_iterator cbegin() const;
24 // const_iterator cend() const;
25 // const_reverse_iterator crbegin() const;
26 // const_reverse_iterator crend() const;
28 #include <set>
29 #include <cassert>
30 #include <cstddef>
32 #include "test_macros.h"
33 #include "min_allocator.h"
35 int main(int, char**)
38 typedef int V;
39 V ar[] =
66 std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
67 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
68 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
69 std::multiset<int>::iterator i;
70 i = m.begin();
71 std::multiset<int>::const_iterator k = i;
72 assert(i == k);
73 for (int j = 1; j <= 8; ++j)
74 for (int n = 0; n < 3; ++n, ++i)
75 assert(*i == j);
76 assert(i == m.end());
77 for (int j = 8; j >= 1; --j)
78 for (int n = 0; n < 3; ++n) {
79 --i;
80 assert(*i == j);
82 assert(i == m.begin());
85 typedef int V;
86 V ar[] =
113 const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
114 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
115 assert(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
116 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
117 assert(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
118 std::multiset<int>::const_iterator i;
119 i = m.begin();
120 for (int j = 1; j <= 8; ++j)
121 for (int k = 0; k < 3; ++k, ++i)
122 assert(*i == j);
123 assert(i == m.end());
124 for (int j = 8; j >= 1; --j)
125 for (int k = 0; k < 3; ++k) {
126 --i;
127 assert(*i == j);
129 assert(i == m.begin());
131 #if TEST_STD_VER >= 11
133 typedef int V;
134 V ar[] =
161 std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
162 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
163 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
164 std::multiset<int, std::less<int>, min_allocator<int>>::iterator i;
165 i = m.begin();
166 std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
167 assert(i == k);
168 for (int j = 1; j <= 8; ++j)
169 for (int n = 0; n < 3; ++n, ++i)
170 assert(*i == j);
171 assert(i == m.end());
172 for (int j = 8; j >= 1; --j)
173 for (int n = 0; n < 3; ++n) {
174 --i;
175 assert(*i == j);
177 assert(i == m.begin());
180 typedef int V;
181 V ar[] =
208 const std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
209 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
210 assert(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
211 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
212 assert(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
213 std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator i;
214 i = m.begin();
215 for (int j = 1; j <= 8; ++j)
216 for (int k = 0; k < 3; ++k, ++i)
217 assert(*i == j);
218 assert(i == m.end());
219 for (int j = 8; j >= 1; --j)
220 for (int k = 0; k < 3; ++k) {
221 --i;
222 assert(*i == j);
224 assert(i == m.begin());
226 #endif
227 #if TEST_STD_VER > 11
228 { // N3644 testing
229 typedef std::multiset<int> C;
230 C::iterator ii1{}, ii2{};
231 C::iterator ii4 = ii1;
232 C::const_iterator cii{};
233 assert ( ii1 == ii2 );
234 assert ( ii1 == ii4 );
236 assert (!(ii1 != ii2 ));
238 assert ( (ii1 == cii ));
239 assert ( (cii == ii1 ));
240 assert (!(ii1 != cii ));
241 assert (!(cii != ii1 ));
243 #endif
245 return 0;