14 #define BOOST_TEST_MODULE ( LazyVector_test ) 15 #include "boost/test/unit_test.hpp" 27 BOOST_TEST(v.empty());
28 BOOST_TEST(v.size() == 0U);
29 BOOST_TEST(v.data_empty());
30 BOOST_TEST(v.data_size() == 0U);
32 BOOST_TEST(v.data_defvalue() == 0);
34 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
35 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
36 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
37 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
44 Vector_t::size_type iBegin = 0, iEnd = 0;
53 BOOST_TEST(!v.empty());
54 BOOST_TEST(v.size() == 10U);
55 BOOST_TEST(!v.data_empty());
56 BOOST_TEST(v.data_size() == iEnd - iBegin);
57 BOOST_TEST(v.data_begin_index() == iBegin);
58 BOOST_TEST(v.data_end_index() == iEnd);
60 BOOST_TEST(v.at (6) == -6);
61 BOOST_TEST(v.const_at (6) == -6);
62 BOOST_TEST(v.get (6) == -6);
63 BOOST_TEST(v.const_get(6) == -6);
64 BOOST_TEST(v [6] == -6);
65 BOOST_TEST(v.data_address(6) == &(v[6]));
67 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
68 BOOST_TEST(v.const_at(i) == v.data_defvalue());
69 BOOST_TEST(v.const_get(i) == v.data_defvalue());
70 BOOST_TEST(v.data_address(i) ==
nullptr);
72 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
73 BOOST_TEST(v.const_at(i) == v.data_defvalue());
74 BOOST_TEST(v.const_get(i) == v.data_defvalue());
75 BOOST_TEST(v.data_address(i) ==
nullptr);
77 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
78 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
79 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
80 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
83 BOOST_TEST(v.data_size() == iEnd - iBegin);
92 BOOST_TEST(!v.empty());
93 BOOST_TEST(v.size() == 10U);
94 BOOST_TEST(!v.data_empty());
95 BOOST_TEST(v.data_size() == iEnd - iBegin);
96 BOOST_TEST(v.data_begin_index() == iBegin);
97 BOOST_TEST(v.data_end_index() == iEnd);
99 BOOST_TEST(v.at (6U) == -6);
100 BOOST_TEST(v.const_at (6U) == -6);
101 BOOST_TEST(v.get (6U) == -6);
102 BOOST_TEST(v.const_get(6U) == -6);
103 BOOST_TEST(v [6U] == -6);
104 BOOST_TEST(v.data_address(6U) == &(v[6U]));
106 BOOST_TEST(v.at (7U) == v.data_defvalue());
107 BOOST_TEST(v.const_at (7U) == v.data_defvalue());
108 BOOST_TEST(v.get (7U) == v.data_defvalue());
109 BOOST_TEST(v.const_get(7U) == v.data_defvalue());
110 BOOST_TEST(v [7U] == v.data_defvalue());
111 BOOST_TEST(v.data_address(7U) == &(v[7U]));
113 BOOST_TEST(v.at (8U) == -8);
114 BOOST_TEST(v.const_at (8U) == -8);
115 BOOST_TEST(v.get (8U) == -8);
116 BOOST_TEST(v.const_get(8U) == -8);
117 BOOST_TEST(v [8U] == -8);
118 BOOST_TEST(v.data_address(8U) == &(v[8U]));
120 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
121 BOOST_TEST(v.const_at(i) == v.data_defvalue());
122 BOOST_TEST(v.const_get(i) == v.data_defvalue());
123 BOOST_TEST(v.data_address(i) ==
nullptr);
125 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
126 BOOST_TEST(v.const_at(i) == v.data_defvalue());
127 BOOST_TEST(v.const_get(i) == v.data_defvalue());
128 BOOST_TEST(v.data_address(i) ==
nullptr);
130 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
131 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
132 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
133 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
136 BOOST_TEST(v.data_size() == iEnd - iBegin);
147 BOOST_TEST(!v.empty());
148 BOOST_TEST(v.size() == 10U);
149 BOOST_TEST(!v.data_empty());
150 BOOST_TEST(v.data_size() == iEnd - iBegin);
151 BOOST_TEST(v.data_begin_index() == iBegin);
152 BOOST_TEST(v.data_end_index() == iEnd);
154 BOOST_TEST(v.at (4U) == -4);
155 BOOST_TEST(v.const_at (4U) == -4);
156 BOOST_TEST(v.get (4U) == -4);
157 BOOST_TEST(v.const_get(4U) == -4);
158 BOOST_TEST(v [4U] == -4);
159 BOOST_TEST(v.data_address(4U) == &(v[4U]));
161 BOOST_TEST(v.at (5U) == v.data_defvalue());
162 BOOST_TEST(v.const_at (5U) == v.data_defvalue());
163 BOOST_TEST(v.get (5U) == v.data_defvalue());
164 BOOST_TEST(v.const_get(5U) == v.data_defvalue());
165 BOOST_TEST(v [5U] == v.data_defvalue());
166 BOOST_TEST(v.data_address(5U) == &(v[5U]));
168 BOOST_TEST(v.at (6U) == -6);
169 BOOST_TEST(v.const_at (6U) == -6);
170 BOOST_TEST(v.get (6U) == -6);
171 BOOST_TEST(v.const_get(6U) == -6);
172 BOOST_TEST(v [6U] == -6);
173 BOOST_TEST(v.data_address(6U) == &(v[6U]));
175 BOOST_TEST(v.at (7U) == v.data_defvalue());
176 BOOST_TEST(v.const_at (7U) == v.data_defvalue());
177 BOOST_TEST(v.get (7U) == v.data_defvalue());
178 BOOST_TEST(v.const_get(7U) == v.data_defvalue());
179 BOOST_TEST(v [7U] == v.data_defvalue());
180 BOOST_TEST(v.data_address(7U) == &(v[7U]));
182 BOOST_TEST(v.at (8U) == -8);
183 BOOST_TEST(v.const_at (8U) == -8);
184 BOOST_TEST(v.get (8U) == -8);
185 BOOST_TEST(v.const_get(8U) == -8);
186 BOOST_TEST(v [8U] == -8);
187 BOOST_TEST(v.data_address(8U) == &(v[8U]));
189 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
190 BOOST_TEST(v.const_at(i) == v.data_defvalue());
191 BOOST_TEST(v.const_get(i) == v.data_defvalue());
192 BOOST_TEST(v.data_address(i) ==
nullptr);
194 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
195 BOOST_TEST(v.const_at(i) == v.data_defvalue());
196 BOOST_TEST(v.const_get(i) == v.data_defvalue());
197 BOOST_TEST(v.data_address(i) ==
nullptr);
199 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
200 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
201 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
202 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
205 BOOST_TEST(v.data_size() == iEnd - iBegin);
214 BOOST_TEST(!v.empty());
215 BOOST_TEST(v.size() == iEnd);
216 BOOST_TEST(!v.data_empty());
217 BOOST_TEST(v.data_size() == iEnd - iBegin);
218 BOOST_TEST(v.data_begin_index() == iBegin);
219 BOOST_TEST(v.data_end_index() == iEnd);
221 BOOST_TEST(v.at (4U) == -4);
222 BOOST_TEST(v.const_at (4U) == -4);
223 BOOST_TEST(v.get (4U) == -4);
224 BOOST_TEST(v.const_get(4U) == -4);
225 BOOST_TEST(v [4U] == -4);
226 BOOST_TEST(v.data_address(4U) == &(v[4U]));
228 BOOST_TEST(v.at (5U) == v.data_defvalue());
229 BOOST_TEST(v.const_at (5U) == v.data_defvalue());
230 BOOST_TEST(v.get (5U) == v.data_defvalue());
231 BOOST_TEST(v.const_get(5U) == v.data_defvalue());
232 BOOST_TEST(v [5U] == v.data_defvalue());
233 BOOST_TEST(v.data_address(5U) == &(v[5U]));
235 BOOST_TEST(v.at (6U) == -6);
236 BOOST_TEST(v.const_at (6U) == -6);
237 BOOST_TEST(v.get (6U) == -6);
238 BOOST_TEST(v.const_get(6U) == -6);
239 BOOST_TEST(v [6U] == -6);
240 BOOST_TEST(v.data_address(6U) == &(v[6U]));
242 BOOST_TEST(v.at (7U) == v.data_defvalue());
243 BOOST_TEST(v.const_at (7U) == v.data_defvalue());
244 BOOST_TEST(v.get (7U) == v.data_defvalue());
245 BOOST_TEST(v.const_get(7U) == v.data_defvalue());
246 BOOST_TEST(v [7U] == v.data_defvalue());
247 BOOST_TEST(v.data_address(7U) == &(v[7U]));
249 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
250 BOOST_TEST(v.const_at(i) == v.data_defvalue());
251 BOOST_TEST(v.const_get(i) == v.data_defvalue());
252 BOOST_TEST(v.data_address(i) ==
nullptr);
254 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
255 BOOST_TEST(v.const_at(i) == v.data_defvalue());
256 BOOST_TEST(v.const_get(i) == v.data_defvalue());
257 BOOST_TEST(v.data_address(i) ==
nullptr);
259 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
260 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
261 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
262 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
265 BOOST_TEST(v.data_size() == iEnd - iBegin);
271 v.resize(v.size() + 10U);
273 BOOST_TEST(!v.empty());
274 BOOST_TEST(v.size() == iEnd + 10U);
275 BOOST_TEST(!v.data_empty());
276 BOOST_TEST(v.data_size() == iEnd - iBegin);
277 BOOST_TEST(v.data_begin_index() == iBegin);
278 BOOST_TEST(v.data_end_index() == iEnd);
280 BOOST_TEST(v.at (4U) == -4);
281 BOOST_TEST(v.const_at (4U) == -4);
282 BOOST_TEST(v.get (4U) == -4);
283 BOOST_TEST(v.const_get(4U) == -4);
284 BOOST_TEST(v [4U] == -4);
285 BOOST_TEST(v.data_address(4U) == &(v[4U]));
287 BOOST_TEST(v.at (5U) == v.data_defvalue());
288 BOOST_TEST(v.const_at (5U) == v.data_defvalue());
289 BOOST_TEST(v.get (5U) == v.data_defvalue());
290 BOOST_TEST(v.const_get(5U) == v.data_defvalue());
291 BOOST_TEST(v [5U] == v.data_defvalue());
292 BOOST_TEST(v.data_address(5U) == &(v[5U]));
294 BOOST_TEST(v.at (6U) == -6);
295 BOOST_TEST(v.const_at (6U) == -6);
296 BOOST_TEST(v.get (6U) == -6);
297 BOOST_TEST(v.const_get(6U) == -6);
298 BOOST_TEST(v [6U] == -6);
299 BOOST_TEST(v.data_address(6U) == &(v[6U]));
301 BOOST_TEST(v.at (7U) == v.data_defvalue());
302 BOOST_TEST(v.const_at (7U) == v.data_defvalue());
303 BOOST_TEST(v.get (7U) == v.data_defvalue());
304 BOOST_TEST(v.const_get(7U) == v.data_defvalue());
305 BOOST_TEST(v [7U] == v.data_defvalue());
306 BOOST_TEST(v.data_address(7U) == &(v[7U]));
308 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
309 BOOST_TEST(v.const_at(i) == v.data_defvalue());
310 BOOST_TEST(v.const_get(i) == v.data_defvalue());
311 BOOST_TEST(v.data_address(i) ==
nullptr);
313 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
314 BOOST_TEST(v.const_at(i) == v.data_defvalue());
315 BOOST_TEST(v.const_get(i) == v.data_defvalue());
316 BOOST_TEST(v.data_address(i) ==
nullptr);
318 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
319 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
320 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
321 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
324 BOOST_TEST(v.data_size() == iEnd - iBegin);
333 BOOST_TEST(!v.empty());
334 BOOST_TEST(v.size() == iEnd);
335 BOOST_TEST(v.data_empty());
336 BOOST_TEST(v.data_size() == iEnd - iBegin);
338 for (Vector_t::size_type i = 0; i < iBegin; ++i) {
339 BOOST_TEST(v.const_at(i) == v.data_defvalue());
340 BOOST_TEST(v.const_get(i) == v.data_defvalue());
341 BOOST_TEST(v.data_address(i) ==
nullptr);
343 for (Vector_t::size_type i = iEnd; i < v.size(); ++i) {
344 BOOST_TEST(v.const_at(i) == v.data_defvalue());
345 BOOST_TEST(v.const_get(i) == v.data_defvalue());
346 BOOST_TEST(v.data_address(i) ==
nullptr);
348 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
349 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
350 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
351 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
354 BOOST_TEST(v.data_size() == iEnd - iBegin);
362 BOOST_TEST(v.empty());
363 BOOST_TEST(v.size() == 0U);
364 BOOST_TEST(v.data_empty());
365 BOOST_TEST(v.data_size() == 0U);
367 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
368 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
369 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
370 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
388 BOOST_TEST(!v.empty());
389 BOOST_TEST(v.size() == 12U);
390 BOOST_TEST(v.data_empty());
391 BOOST_TEST(v.data_size() == 0U);
393 BOOST_TEST(v.data_defvalue() == 5);
395 for (Vector_t::size_type i = 0; i < v.size(); ++i) {
396 BOOST_TEST(v.const_at(i) == v.data_defvalue());
397 BOOST_TEST(v.const_get(i) == v.data_defvalue());
400 BOOST_CHECK_THROW(v.at(v.size()), std::out_of_range);
401 BOOST_CHECK_THROW(v.const_at(v.size()), std::out_of_range);
402 BOOST_CHECK_THROW(v.at(v.size() + 1U), std::out_of_range);
403 BOOST_CHECK_THROW(v.const_at(v.size() + 1U), std::out_of_range);
420 BOOST_TEST(v.
size() == 6U);
433 BOOST_TEST(v.size() == 6U);
434 BOOST_TEST(v.data_size() == 1U);
435 BOOST_TEST(v.at(4U) == -4.0);
447 BOOST_TEST(v.size() == 6U);
448 BOOST_TEST(v.data_size() == 3U);
449 BOOST_TEST(v.at(2U) == -2.0);
450 BOOST_TEST(v.at(3U) == v.data_defvalue());
451 BOOST_TEST(v.at(4U) == -4.0);
465 BOOST_TEST(v.size() == 7U);
466 BOOST_TEST(v.data_size() == 5U);
467 BOOST_TEST(v.at(2U) == -2.0);
468 BOOST_TEST(v.at(3U) == v.data_defvalue());
469 BOOST_TEST(v.at(4U) == -4.0);
470 BOOST_TEST(v.at(5U) == v.data_defvalue());
471 BOOST_TEST(v.at(6U) == -6.0);
BOOST_AUTO_TEST_CASE(LazyVectorTestCase)
value_type const_get(size_type pos) const
size_type size() const noexcept
Returns the size of the vector.
void TestLazyVector_documentation_constructor_size()
bool data_empty() const noexcept
Returns whether no data is actually stored.
void TestLazyVector_defaultConstructed()
Contiguous data container with lazy resizing on access.
void TestLazyVector_documentation_class()
A contiguous data container expanded on write.
void TestLazyVector_sizeConstructed()
recob::tracking::Vector_t Vector_t