Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / multiset / lower_bound.pass.cpp
blobd391da8ab0f7047cdb923c754407d592bfcf19d6
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 lower_bound(const key_type& k);
14 // const_iterator lower_bound(const key_type& k) const;
16 #include <set>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 #include "private_constructor.h"
23 int main(int, char**)
26 typedef int V;
27 typedef std::multiset<int> M;
29 typedef M::iterator R;
30 V ar[] =
42 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
43 R r = m.lower_bound(4);
44 assert(r == std::next(m.begin(), 0));
45 r = m.lower_bound(5);
46 assert(r == std::next(m.begin(), 0));
47 r = m.lower_bound(6);
48 assert(r == std::next(m.begin(), 3));
49 r = m.lower_bound(7);
50 assert(r == std::next(m.begin(), 3));
51 r = m.lower_bound(8);
52 assert(r == std::next(m.begin(), 6));
53 r = m.lower_bound(9);
54 assert(r == std::next(m.begin(), 6));
55 r = m.lower_bound(11);
56 assert(r == std::next(m.begin(), 9));
59 typedef M::const_iterator R;
60 V ar[] =
72 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
73 R r = m.lower_bound(4);
74 assert(r == std::next(m.begin(), 0));
75 r = m.lower_bound(5);
76 assert(r == std::next(m.begin(), 0));
77 r = m.lower_bound(6);
78 assert(r == std::next(m.begin(), 3));
79 r = m.lower_bound(7);
80 assert(r == std::next(m.begin(), 3));
81 r = m.lower_bound(8);
82 assert(r == std::next(m.begin(), 6));
83 r = m.lower_bound(9);
84 assert(r == std::next(m.begin(), 6));
85 r = m.lower_bound(11);
86 assert(r == std::next(m.begin(), 9));
89 #if TEST_STD_VER >= 11
91 typedef int V;
92 typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
94 typedef M::iterator R;
95 V ar[] =
107 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
108 R r = m.lower_bound(4);
109 assert(r == std::next(m.begin(), 0));
110 r = m.lower_bound(5);
111 assert(r == std::next(m.begin(), 0));
112 r = m.lower_bound(6);
113 assert(r == std::next(m.begin(), 3));
114 r = m.lower_bound(7);
115 assert(r == std::next(m.begin(), 3));
116 r = m.lower_bound(8);
117 assert(r == std::next(m.begin(), 6));
118 r = m.lower_bound(9);
119 assert(r == std::next(m.begin(), 6));
120 r = m.lower_bound(11);
121 assert(r == std::next(m.begin(), 9));
124 typedef M::const_iterator R;
125 V ar[] =
137 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
138 R r = m.lower_bound(4);
139 assert(r == std::next(m.begin(), 0));
140 r = m.lower_bound(5);
141 assert(r == std::next(m.begin(), 0));
142 r = m.lower_bound(6);
143 assert(r == std::next(m.begin(), 3));
144 r = m.lower_bound(7);
145 assert(r == std::next(m.begin(), 3));
146 r = m.lower_bound(8);
147 assert(r == std::next(m.begin(), 6));
148 r = m.lower_bound(9);
149 assert(r == std::next(m.begin(), 6));
150 r = m.lower_bound(11);
151 assert(r == std::next(m.begin(), 9));
154 #endif
155 #if TEST_STD_VER > 11
157 typedef int V;
158 typedef std::multiset<V, std::less<>> M;
160 typedef M::iterator R;
161 V ar[] =
173 M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
175 R r = m.lower_bound(4);
176 assert(r == std::next(m.begin(), 0));
177 r = m.lower_bound(5);
178 assert(r == std::next(m.begin(), 0));
179 r = m.lower_bound(6);
180 assert(r == std::next(m.begin(), 3));
181 r = m.lower_bound(7);
182 assert(r == std::next(m.begin(), 3));
183 r = m.lower_bound(8);
184 assert(r == std::next(m.begin(), 6));
185 r = m.lower_bound(9);
186 assert(r == std::next(m.begin(), 6));
187 r = m.lower_bound(11);
188 assert(r == std::next(m.begin(), 9));
192 typedef PrivateConstructor V;
193 typedef std::multiset<V, std::less<>> M;
194 typedef M::iterator R;
196 M m;
197 m.insert ( V::make ( 5 ));
198 m.insert ( V::make ( 5 ));
199 m.insert ( V::make ( 5 ));
200 m.insert ( V::make ( 7 ));
201 m.insert ( V::make ( 7 ));
202 m.insert ( V::make ( 7 ));
203 m.insert ( V::make ( 9 ));
204 m.insert ( V::make ( 9 ));
205 m.insert ( V::make ( 9 ));
207 R r = m.lower_bound(4);
208 assert(r == std::next(m.begin(), 0));
209 r = m.lower_bound(5);
210 assert(r == std::next(m.begin(), 0));
211 r = m.lower_bound(6);
212 assert(r == std::next(m.begin(), 3));
213 r = m.lower_bound(7);
214 assert(r == std::next(m.begin(), 3));
215 r = m.lower_bound(8);
216 assert(r == std::next(m.begin(), 6));
217 r = m.lower_bound(9);
218 assert(r == std::next(m.begin(), 6));
219 r = m.lower_bound(11);
220 assert(r == std::next(m.begin(), 9));
222 #endif
224 return 0;