[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / set / iterator.pass.cpp
blob4ac1187dddc71b05f7d0181bc6bab8a83f8ef70f
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 set
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::set<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::set<int>::iterator i;
70 i = m.begin();
71 std::set<int>::const_iterator k = i;
72 assert(i == k);
73 for (int j = 1; j <= static_cast<int>(m.size()); ++j, ++i)
74 assert(*i == j);
75 assert(i == m.end());
76 for (int j = static_cast<int>(m.size()); j >= 1; --j) {
77 --i;
78 assert(*i == j);
80 assert(i == m.begin());
83 typedef int V;
84 V ar[] =
111 const std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
112 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
113 assert(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
114 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
115 assert(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
116 std::set<int>::const_iterator i;
117 i = m.begin();
118 for (int j = 1; j <= static_cast<int>(m.size()); ++j, ++i)
119 assert(*i == j);
120 assert(i == m.end());
121 for (int j = static_cast<int>(m.size()); j >= 1; --j) {
122 --i;
123 assert(*i == j);
125 assert(i == m.begin());
127 #if TEST_STD_VER >= 11
129 typedef int V;
130 V ar[] =
157 std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
158 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
159 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
160 std::set<int, std::less<int>, min_allocator<int>>::iterator i;
161 i = m.begin();
162 std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
163 assert(i == k);
164 for (int j = 1; j <= static_cast<int>(m.size()); ++j, ++i)
165 assert(*i == j);
166 assert(i == m.end());
167 for (int j = static_cast<int>(m.size()); j >= 1; --j) {
168 --i;
169 assert(*i == j);
171 assert(i == m.begin());
174 typedef int V;
175 V ar[] =
202 const std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
203 assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
204 assert(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
205 assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
206 assert(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
207 std::set<int, std::less<int>, min_allocator<int>>::const_iterator i;
208 i = m.begin();
209 for (int j = 1; j <= static_cast<int>(m.size()); ++j, ++i)
210 assert(*i == j);
211 assert(i == m.end());
212 for (int j = static_cast<int>(m.size()); j >= 1; --j) {
213 --i;
214 assert(*i == j);
216 assert(i == m.begin());
218 #endif
219 #if TEST_STD_VER > 11
220 { // N3644 testing
221 typedef std::set<int> C;
222 C::iterator ii1{}, ii2{};
223 C::iterator ii4 = ii1;
224 C::const_iterator cii{};
225 assert ( ii1 == ii2 );
226 assert ( ii1 == ii4 );
228 assert (!(ii1 != ii2 ));
230 assert ( (ii1 == cii ));
231 assert ( (cii == ii1 ));
232 assert (!(ii1 != cii ));
233 assert (!(cii != ii1 ));
235 #endif
237 return 0;