@@ -96,12 +96,30 @@ namespace xtd::collections::generic::helpers::tests {
9696 assert::are_equal (21 , inners.back ());
9797 }
9898
99+ void test_method_ (items_const) {
100+ const auto items = raw_queue<int >(std::deque<int > {84 , 42 , 21 });
101+ assert::are_equal (typeof_<raw_queue<int >::base_type>(), typeof_ (items.items ()));
102+
103+ const auto & inners = items.items ();
104+ assert::are_equal (84 , inners.front ());
105+ assert::are_equal (21 , inners.back ());
106+ }
107+
99108 void test_method_ (begin) {
100109 auto items = raw_queue<int >(std::deque<int > {84 , 42 , 21 });
101110 assert::are_equal (typeof_<int >(), typeof_ (*items.begin ()));
102111 assert::are_equal (84 , *items.begin ());
103112 }
104113
114+ void test_method_ (capaciy) {
115+ auto items = raw_queue<int >(std::deque<int > {84 , 42 , 21 });
116+ assert::are_equal (3_z, items.size ());
117+
118+ items.reserve (42 );
119+ assert::is_greater_or_equal (items.capacity (), 42_z);
120+ assert::are_equal (3_z, items.size ());
121+ }
122+
105123 void test_method_ (cbegin) {
106124 auto items = raw_queue<int >(std::deque<int > {84 , 42 , 21 });
107125 assert::are_equal (typeof_<int >(), typeof_ (*items.begin ()));
@@ -125,206 +143,6 @@ namespace xtd::collections::generic::helpers::tests {
125143 }
126144
127145 /*
128- void test_method_(const_back) {
129- assert::are_equal(21, raw_queue {84, 42, 21}.back());
130- assert::throws<std::out_of_range>([] {raw_queue<int> {}.back();});
131- }
132-
133- void test_method_(const_back_with_bool) {
134- assert::are_equal(true, raw_queue {true, false, true}.back());
135- assert::throws<std::out_of_range>([] {raw_queue<bool> {}.back();});
136- }
137-
138- void test_method_(back) {
139- auto items = raw_queue {84, 42, 21};
140- items.back() = 5;
141- assert::are_equal(5, items.back());
142- auto empty_items = raw_queue<int> {};
143- assert::throws<std::out_of_range>([&] {empty_items.back() = 5;});
144- }
145-
146- void test_method_(back_with_bool) {
147- auto items = raw_queue {true, false, true};
148- items.back() = false;
149- assert::are_equal(false, items.back());
150- auto empty_items = raw_queue<bool> {};
151- assert::throws<std::out_of_range>([&] {empty_items.back() = false;});
152- }
153-
154- void test_method_(begin_with_bool) {
155- auto items = raw_queue {true, false, true, false};
156- assert::are_equal(typeof_<bool>(), typeof_(*items.begin()));
157- assert::are_equal(true, *items.begin());
158- }
159-
160- void test_method_(capaciy) {
161- auto items = raw_queue {84, 42, 21};
162- assert::are_equal(3_z, items.size());
163-
164- items.reserve(42);
165- assert::is_greater_or_equal(items.capacity(), 42_z);
166- assert::are_equal(3_z, items.size());
167- }
168-
169- void test_method_(capaciy_with_bool) {
170- auto items = raw_queue {true, false, true};
171- assert::are_equal(3_z, items.size());
172-
173- items.reserve(42);
174- assert::is_greater_or_equal(items.capacity(), 42_z);
175- assert::are_equal(3_z, items.size());
176- }
177-
178- void test_method_(crbegin) {
179- auto items = raw_queue {84, 42, 21};
180- assert::are_equal(typeof_<int>(), typeof_(*items.crbegin()));
181- assert::are_equal(21, *items.crbegin());
182- }
183-
184- void test_method_(crbegin_with_bool) {
185- auto items = raw_queue {true, false, true, false};
186- assert::are_equal(typeof_<bool>(), typeof_(*items.crbegin()));
187- assert::are_equal(false, *items.crbegin());
188- }
189-
190- void test_method_(crend) {
191- auto items = raw_queue {84, 42, 21};
192- // the crend() property unlike end() and cend() is the same as underlying value type (std::vector) so this element acts as a placeholder, attempting to access it results in undefined behavior.
193- // see https://en.cppreference.com/w/cpp/container/vector/rend documentation
194- //assert::throws<std::out_of_range>([&] {*items.crend();});
195- assert::is_true(items.crend() == items.crbegin() + items.size());
196- }
197-
198- void test_method_(crend_with_bool) {
199- auto items = raw_queue {true, false, true, false};
200- // the crend() property unlike end() and cend() is the same as underlying value type (std::vector) so this element acts as a placeholder, attempting to access it results in undefined behavior.
201- // see https://en.cppreference.com/w/cpp/container/vector/rend documentation
202- //assert::throws<std::out_of_range>([&] {*items.crend();});
203- assert::is_true(items.crend() == items.crbegin() + items.size());
204- }
205-
206- void test_method_(data) {
207- auto items = raw_queue {84, 42, 21};
208-
209- auto ptr = items.data();
210- assert::are_equal(84, *ptr);
211- assert::are_equal(42, *(ptr + 1));
212- assert::are_equal(21, *(ptr + 2));
213-
214- // Attempting to access a pointer that exceeds size() results in undefined behaviour.
215- //assert::are_equal(0, *(ptr + 3));
216-
217- *(ptr) = 63;
218- *(ptr + 1) = 31;
219- *(ptr + 2) = 10;
220-
221- // Attempting to access a pointer that exceeds size() results in undefined behaviour.
222- // *(ptr + 3) = 6;
223-
224- collection_assert::are_equal({63, 31, 10}, items);
225- }
226-
227- void test_method_(data_with_bool) {
228- auto items = raw_queue {true, false, true};
229-
230- auto ptr = items.data();
231- assert::are_equal(true, *ptr);
232- assert::are_equal(false, *(ptr + 1));
233- assert::are_equal(true, *(ptr + 2));
234-
235- // Attempting to access a pointer that exceeds size() results in undefined behaviour.
236- //assert::are_equal(false, *(ptr + 3));
237-
238- *(ptr) = false;
239- *(ptr + 1) = true;
240- *(ptr + 2) = false;
241-
242- // Attempting to access a pointer that exceeds size() results in undefined behaviour.
243- // *(ptr + 3) = true;
244-
245- collection_assert::are_equal({false, true, false}, items);
246- }
247-
248- void test_method_(empty) {
249- assert::is_true(raw_queue<int> {}.empty());
250- assert::is_false(raw_queue<int> {42}.empty());
251-
252- auto items = raw_queue<int> {};
253- assert::is_true(items.empty());
254- items.reserve(42);
255- assert::is_true(items.empty());
256- items.resize(1);
257- assert::is_false(items.empty());
258- items.resize(0);
259- assert::is_true(items.empty());
260- items.push_back(42);
261- assert::is_false(items.empty());
262- }
263-
264- void test_method_(empty_with_bool) {
265- assert::is_true(raw_queue<bool> {}.empty());
266- assert::is_false(raw_queue<bool> {true}.empty());
267-
268- auto items = raw_queue<int> {};
269- assert::is_true(items.empty());
270- items.reserve(42);
271- assert::is_true(items.empty());
272- items.resize(1);
273- assert::is_false(items.empty());
274- items.resize(0);
275- assert::is_true(items.empty());
276- items.push_back(true);
277- assert::is_false(items.empty());
278- }
279-
280- void test_method_(end) {
281- auto items = raw_queue {84, 42, 21};
282- // the crend() property unlike end() and cend() is the same as underlying value type (std::vector) so this element acts as a placeholder, attempting to access it results in undefined behavior.
283- // see https://en.cppreference.com/w/cpp/container/vector/rend documentation
284- //assert::throws<std::out_of_range>([&] {*items.end();});
285- assert::is_true(items.end() == items.begin() + items.size());
286- }
287-
288- void test_method_(end_with_bool) {
289- auto items = raw_queue {true, false, true};
290- // the crend() property unlike end() and cend() is the same as underlying value type (std::vector) so this element acts as a placeholder, attempting to access it results in undefined behavior.
291- // see https://en.cppreference.com/w/cpp/container/vector/rend documentation
292- //assert::throws<std::out_of_range>([&] {*items.end();});
293- assert::is_true(items.end() == items.begin() + items.size());
294- }
295-
296- void test_method_(front_const) {
297- auto items = raw_queue {84, 42, 21};
298- assert::are_equal(84, items.front());
299- assert::throws<std::out_of_range>([&] {raw_queue<int> {}.front();});
300- }
301-
302- void test_method_(front_const_with_bool) {
303- auto items = raw_queue {true, false, true};
304- assert::are_equal(true, items.front());
305- assert::throws<std::out_of_range>([&] {raw_queue<bool> {}.front();});
306- }
307-
308- void test_method_(front) {
309- auto items = raw_queue {84, 42, 21};
310- items.front() = 10;
311- assert::are_equal(10, items.front());
312- auto empty_items = raw_queue<int> {};
313- assert::throws<std::out_of_range>([&] {empty_items.front() = 10;});
314- }
315-
316- void test_method_(front_with_bool) {
317- auto items = raw_queue {true, false, true};
318- items.front() = false;
319- assert::are_equal(false, items.front());
320- auto empty_items = raw_queue<bool> {};
321- assert::throws<std::out_of_range>([&] {empty_items.front() = true;});
322- }
323-
324- void test_method_(items_const) {
325- assert::are_equal(typeof_<raw_queue<int>::base_type>(), typeof_(raw_queue {1, 2, 3, 4, 5}.items()));
326- collection_assert::are_equal({1, 2, 3, 4, 5}, raw_queue {1, 2, 3, 4, 5}.items());
327- }
328146
329147 void test_method_(items_const_with_bool) {
330148 assert::are_equal(typeof_<raw_queue<bool>::base_type>(), typeof_(raw_queue {true, false, true, false}.items()));
0 commit comments