9 #define BOOST_TEST_MODULE (geometry data containers test)
10 #include <boost/test/unit_test.hpp>
27 T
get()
const {
return sum; }
35 std::size_t
const NCryostats, std::size_t
const NTPCs
38 std::size_t
const N = NCryostats * NTPCs;
41 BOOST_TEST(data.
dimSize<0U>() == NCryostats);
42 BOOST_TEST(data.
dimSize<1U>() == NTPCs);
43 BOOST_TEST(data.
dimSize<2U>() == 0U);
44 BOOST_TEST(data.
dimSize<3U>() == 0U);
46 BOOST_TEST(!data.
empty());
47 BOOST_TEST(data.
size() ==
N);
50 for (
auto c: util::counter<unsigned int>(NCryostats))
51 for (
auto t: util::counter<unsigned int>(NTPCs))
52 BOOST_TEST((data[{ c, t }]) == 0);
58 std::size_t expected_index = 0U;
61 for (
auto&
value: data) {
62 static_assert(std::is_same_v<decltype(
value), decltype(data)::reference>);
64 geo::TPCID const expected_ID = data.mapper().ID(expected_index);
65 BOOST_TEST(
value == data[expected_ID]);
69 BOOST_TEST(data.size() == expected_index);
73 for (
auto&& [ ID,
value ]: data.items()) {
74 static_assert(std::is_same_v<decltype(ID),
geo::TPCID>);
75 static_assert(std::is_same_v<decltype(
value), decltype(data)::reference>);
77 geo::TPCID const expected_ID = data.mapper().ID(expected_index);
78 BOOST_TEST(ID == expected_ID);
79 BOOST_TEST(
value == data[expected_ID]);
83 BOOST_TEST(data.size() == expected_index);
86 BOOST_TEST( data.hasTPC({ 0, 0}));
87 BOOST_TEST( data.hasTPC({ 0, 1}));
88 BOOST_TEST( data.hasTPC({ 0, 2}));
89 BOOST_TEST(!data.hasTPC({ 0, 3}));
90 BOOST_TEST(!data.hasTPC({ 0, 4}));
91 BOOST_TEST( data.hasTPC({ 1, 0}));
92 BOOST_TEST( data.hasTPC({ 1, 1}));
93 BOOST_TEST( data.hasTPC({ 1, 2}));
94 BOOST_TEST(!data.hasTPC({ 1, 3}));
95 BOOST_TEST(!data.hasTPC({ 1, 4}));
96 BOOST_TEST(!data.hasTPC({ 2, 0}));
97 BOOST_TEST(!data.hasTPC({ 2, 1}));
98 BOOST_TEST(!data.hasTPC({ 2, 2}));
99 BOOST_TEST(!data.hasTPC({ 2, 3}));
100 BOOST_TEST(!data.hasTPC({ 2, 4}));
102 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 0, 0}));
103 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 0, 1}));
104 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 0, 2}));
105 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 0, 3}));
106 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 0, 4}));
107 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 1, 0}));
108 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 1, 1}));
109 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 1, 2}));
110 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 1, 3}));
111 BOOST_TEST( data.hasCryostat(
geo::TPCID{ 1, 4}));
112 BOOST_TEST(!data.hasCryostat(
geo::TPCID{ 2, 0}));
113 BOOST_TEST(!data.hasCryostat(
geo::TPCID{ 2, 1}));
114 BOOST_TEST(!data.hasCryostat(
geo::TPCID{ 2, 2}));
115 BOOST_TEST(!data.hasCryostat(
geo::TPCID{ 2, 3}));
116 BOOST_TEST(!data.hasCryostat(
geo::TPCID{ 2, 4}));
119 BOOST_TEST((data[{0, 0}]) == 4);
120 BOOST_TEST(data.at({0, 0}) == 4);
122 BOOST_TEST((data[{0, 0}]) == 5);
123 BOOST_TEST(data.at({0, 0}) == 5);
126 BOOST_TEST((data[{0, 1}]) == 6);
127 BOOST_TEST(data.at({0, 1}) == 6);
129 BOOST_TEST((data[{0, 0}]) == 5);
132 BOOST_TEST((data[{0, 2}]) == 7);
133 BOOST_TEST(data.at({0, 2}) == 7);
135 BOOST_TEST((data[{0, 0}]) == 5);
136 BOOST_TEST((data[{0, 1}]) == 6);
139 BOOST_TEST((data[{1, 0}]) == 15);
140 BOOST_TEST(data.at({1, 0}) == 15);
142 BOOST_TEST((data[{0, 0}]) == 5);
143 BOOST_TEST((data[{0, 1}]) == 6);
144 BOOST_TEST((data[{0, 2}]) == 7);
147 BOOST_TEST((data[{1, 1}]) == 16);
148 BOOST_TEST(data.at({1, 1}) == 16);
150 BOOST_TEST((data[{0, 0}]) == 5);
151 BOOST_TEST((data[{0, 1}]) == 6);
152 BOOST_TEST((data[{0, 2}]) == 7);
153 BOOST_TEST((data[{1, 0}]) == 15);
156 BOOST_TEST((data[{1, 2}]) == 17);
157 BOOST_TEST(data.at({1, 2}) == 17);
159 BOOST_TEST((data[{0, 0}]) == 5);
160 BOOST_TEST((data[{0, 1}]) == 6);
161 BOOST_TEST((data[{0, 2}]) == 7);
162 BOOST_TEST((data[{1, 0}]) == 15);
163 BOOST_TEST((data[{1, 1}]) == 16);
165 BOOST_CHECK_THROW(data.at({0, 3}), std::out_of_range);
166 BOOST_CHECK_THROW(data.at({0, 4}), std::out_of_range);
167 BOOST_CHECK_THROW(data.at({1, 3}), std::out_of_range);
168 BOOST_CHECK_THROW(data.at({1, 4}), std::out_of_range);
169 BOOST_CHECK_THROW(data.at({2, 0}), std::out_of_range);
170 BOOST_CHECK_THROW(data.at({2, 1}), std::out_of_range);
171 BOOST_CHECK_THROW(data.at({2, 2}), std::out_of_range);
172 BOOST_CHECK_THROW(data.at({2, 3}), std::out_of_range);
173 BOOST_CHECK_THROW(data.at({2, 4}), std::out_of_range);
175 BOOST_TEST(data.first() == 5);
177 BOOST_TEST((data[{0, 0}]) == -5);
178 BOOST_TEST(data.first() == -5);
181 BOOST_TEST(data.last() == 17);
183 BOOST_TEST((data[{1U, 2U}]) == -17);
184 BOOST_TEST(data.last() == -17);
187 auto const& constData = data;
189 BOOST_TEST(constData.size() ==
N);
191 static_assert(std::decay_t<decltype(constData)>::
dimensions() == 2U);
192 BOOST_TEST(constData.dimSize<0U>() == NCryostats);
193 BOOST_TEST(constData.dimSize<1U>() == NTPCs);
194 BOOST_TEST(constData.dimSize<2U>() == 0U);
195 BOOST_TEST(constData.dimSize<3U>() == 0U);
198 (std::addressof(constData.first()) == std::addressof(data.first()));
200 (std::addressof(constData.last()) == std::addressof(data.last()));
202 BOOST_TEST((constData[{0, 0}]) == (data[{0, 0}]));
203 BOOST_TEST((constData[{0, 1}]) == (data[{0, 1}]));
204 BOOST_TEST((constData[{0, 2}]) == (data[{0, 2}]));
205 BOOST_TEST((constData[{1, 0}]) == (data[{1, 0}]));
206 BOOST_TEST((constData[{1, 1}]) == (data[{1, 1}]));
207 BOOST_TEST((constData[{1, 2}]) == (data[{1, 2}]));
208 BOOST_TEST(constData.at({0, 0}) == data.at({0, 0}));
209 BOOST_TEST(constData.at({0, 1}) == data.at({0, 1}));
210 BOOST_TEST(constData.at({0, 2}) == data.at({0, 2}));
211 BOOST_TEST(constData.at({1, 0}) == data.at({1, 0}));
212 BOOST_TEST(constData.at({1, 1}) == data.at({1, 1}));
213 BOOST_TEST(constData.at({1, 2}) == data.at({1, 2}));
215 BOOST_CHECK_THROW(constData.at({0, 3}), std::out_of_range);
216 BOOST_CHECK_THROW(constData.at({0, 4}), std::out_of_range);
217 BOOST_CHECK_THROW(constData.at({1, 3}), std::out_of_range);
218 BOOST_CHECK_THROW(constData.at({1, 4}), std::out_of_range);
219 BOOST_CHECK_THROW(constData.at({2, 0}), std::out_of_range);
220 BOOST_CHECK_THROW(constData.at({2, 1}), std::out_of_range);
221 BOOST_CHECK_THROW(constData.at({2, 2}), std::out_of_range);
222 BOOST_CHECK_THROW(constData.at({2, 3}), std::out_of_range);
223 BOOST_CHECK_THROW(constData.at({2, 4}), std::out_of_range);
226 auto const cb = constData.begin();
227 auto const ce = constData.end();
228 BOOST_TEST(static_cast<size_t>(ce - cb) ==
N);
232 for (
auto&
value: constData) {
233 static_assert(std::is_same_v
234 <decltype(
value), std::decay_t<decltype(constData)>::const_reference>
237 geo::TPCID const expected_ID = constData.mapper().ID(expected_index);
238 BOOST_TEST(
value == constData[expected_ID]);
242 BOOST_TEST(constData.size() == expected_index);
246 for (
auto&& [ ID,
value ]: constData.items()) {
247 static_assert(std::is_same_v<decltype(ID),
geo::TPCID>);
248 static_assert(std::is_same_v
249 <decltype(
value), std::decay_t<decltype(constData)>::const_reference>
252 geo::TPCID const expected_ID = constData.mapper().ID(expected_index);
253 BOOST_TEST(ID == expected_ID);
254 BOOST_TEST(
value == constData[expected_ID]);
258 BOOST_TEST(constData.size() == expected_index);
262 for (
auto c: util::counter<unsigned int>(NCryostats))
263 for (
auto t: util::counter<unsigned int>(NTPCs))
264 BOOST_TEST((data[{ c, t }]) == 14);
266 data.apply([](
int& v){ v *= 2; });
267 for (
auto c: util::counter<unsigned int>(NCryostats))
268 for (
auto t: util::counter<unsigned int>(NTPCs))
269 BOOST_TEST((data[{ c, t }]) == 28);
272 static_assert(std::is_same_v<decltype(data.apply(summer)),
Summer<int>&>);
274 BOOST_TEST(summer.
get() ==
N * 28);
278 (std::is_same_v<decltype(constData.apply(summer)),
Summer<int>&>);
279 constData.apply(summer);
280 BOOST_TEST(summer.
get() ==
N * 28);
283 BOOST_TEST(summer1.get() ==
N * 28);
286 BOOST_TEST(summer2.get() ==
N * 28);
289 for (
auto c: util::counter<unsigned int>(NCryostats))
290 for (
auto t: util::counter<unsigned int>(NTPCs))
291 BOOST_TEST((data[{ c, t }]) == 0);
294 BOOST_TEST(data.empty());
302 std::size_t
const NCryostats,
303 std::size_t
const NTPCs,
304 std::size_t
const NPlanes
307 std::size_t
const N = NCryostats * NTPCs * NPlanes;
310 BOOST_TEST(data.
dimSize<0U>() == NCryostats);
311 BOOST_TEST(data.
dimSize<1U>() == NTPCs);
312 BOOST_TEST(data.
dimSize<2U>() == NPlanes);
313 BOOST_TEST(data.
dimSize<3U>() == 0U);
315 BOOST_TEST(!data.
empty());
316 BOOST_TEST(data.
size() ==
N);
319 for (
auto c: util::counter<unsigned int>(NCryostats))
320 for (
auto t: util::counter<unsigned int>(NTPCs))
321 for (
auto p: util::counter<unsigned int>(NPlanes))
322 BOOST_TEST((data[{ c, t,
p }]) == 0);
328 std::size_t expected_index = 0U;
331 for (
auto&
value: data) {
332 static_assert(std::is_same_v<decltype(
value), decltype(data)::reference>);
334 geo::PlaneID const expected_ID = data.mapper().ID(expected_index);
335 BOOST_TEST(
value == data[expected_ID]);
339 BOOST_TEST(data.size() == expected_index);
343 for (
auto&& [ ID,
value ]: data.items()) {
344 static_assert(std::is_same_v<decltype(ID),
geo::PlaneID>);
345 static_assert(std::is_same_v<decltype(
value), decltype(data)::reference>);
347 geo::PlaneID const expected_ID = data.mapper().ID(expected_index);
348 BOOST_TEST(ID == expected_ID);
349 BOOST_TEST(
value == data[expected_ID]);
353 BOOST_TEST(data.size() == expected_index);
355 BOOST_TEST( data.hasPlane({ 0, 0, 0}));
356 BOOST_TEST( data.hasPlane({ 0, 0, 1}));
357 BOOST_TEST(!data.hasPlane({ 0, 0, 2}));
358 BOOST_TEST( data.hasPlane({ 0, 1, 0}));
359 BOOST_TEST( data.hasPlane({ 0, 1, 1}));
360 BOOST_TEST(!data.hasPlane({ 0, 1, 2}));
361 BOOST_TEST( data.hasPlane({ 0, 2, 0}));
362 BOOST_TEST( data.hasPlane({ 0, 2, 1}));
363 BOOST_TEST(!data.hasPlane({ 0, 2, 2}));
364 BOOST_TEST(!data.hasPlane({ 0, 3, 0}));
365 BOOST_TEST(!data.hasPlane({ 0, 3, 1}));
366 BOOST_TEST(!data.hasPlane({ 0, 3, 2}));
367 BOOST_TEST(!data.hasPlane({ 0, 4, 0}));
368 BOOST_TEST(!data.hasPlane({ 0, 4, 1}));
369 BOOST_TEST(!data.hasPlane({ 0, 4, 2}));
370 BOOST_TEST( data.hasPlane({ 1, 0, 0}));
371 BOOST_TEST( data.hasPlane({ 1, 0, 1}));
372 BOOST_TEST(!data.hasPlane({ 1, 0, 2}));
373 BOOST_TEST( data.hasPlane({ 1, 1, 0}));
374 BOOST_TEST( data.hasPlane({ 1, 1, 1}));
375 BOOST_TEST(!data.hasPlane({ 1, 1, 2}));
376 BOOST_TEST( data.hasPlane({ 1, 2, 0}));
377 BOOST_TEST( data.hasPlane({ 1, 2, 1}));
378 BOOST_TEST(!data.hasPlane({ 1, 2, 2}));
379 BOOST_TEST(!data.hasPlane({ 1, 3, 0}));
380 BOOST_TEST(!data.hasPlane({ 1, 3, 1}));
381 BOOST_TEST(!data.hasPlane({ 1, 3, 2}));
382 BOOST_TEST(!data.hasPlane({ 1, 4, 0}));
383 BOOST_TEST(!data.hasPlane({ 1, 4, 1}));
384 BOOST_TEST(!data.hasPlane({ 1, 4, 2}));
385 BOOST_TEST(!data.hasPlane({ 2, 0, 0}));
386 BOOST_TEST(!data.hasPlane({ 2, 0, 1}));
387 BOOST_TEST(!data.hasPlane({ 2, 0, 2}));
388 BOOST_TEST(!data.hasPlane({ 2, 1, 0}));
389 BOOST_TEST(!data.hasPlane({ 2, 1, 1}));
390 BOOST_TEST(!data.hasPlane({ 2, 1, 2}));
391 BOOST_TEST(!data.hasPlane({ 2, 2, 0}));
392 BOOST_TEST(!data.hasPlane({ 2, 2, 1}));
393 BOOST_TEST(!data.hasPlane({ 2, 2, 2}));
394 BOOST_TEST(!data.hasPlane({ 2, 3, 0}));
395 BOOST_TEST(!data.hasPlane({ 2, 3, 1}));
396 BOOST_TEST(!data.hasPlane({ 2, 3, 2}));
397 BOOST_TEST(!data.hasPlane({ 2, 4, 0}));
398 BOOST_TEST(!data.hasPlane({ 2, 4, 1}));
399 BOOST_TEST(!data.hasPlane({ 2, 4, 2}));
495 BOOST_TEST( (data[{0, 0, 0}]) == 4);
496 BOOST_TEST(data.at({0, 0, 0}) == 4);
498 BOOST_TEST( (data[{0, 0, 0}]) == 5);
499 BOOST_TEST(data.at({0, 0, 0}) == 5);
502 BOOST_TEST( (data[{0, 0, 1}]) == 6);
503 BOOST_TEST(data.at({0, 0, 1}) == 6);
505 BOOST_TEST( (data[{0, 0, 0}]) == 5);
507 data[{0, 1, 0}] = 15;
508 BOOST_TEST( (data[{0, 1, 0}]) == 15);
509 BOOST_TEST(data.at({0, 1, 0}) == 15);
511 BOOST_TEST( (data[{0, 0, 0}]) == 5);
512 BOOST_TEST( (data[{0, 0, 1}]) == 6);
514 data[{0, 1, 1}] = 16;
515 BOOST_TEST( (data[{0, 1, 1}]) == 16);
516 BOOST_TEST(data.at({0, 1, 1}) == 16);
518 BOOST_TEST( (data[{0, 0, 0}]) == 5);
519 BOOST_TEST( (data[{0, 0, 1}]) == 6);
520 BOOST_TEST( (data[{0, 1, 0}]) == 15);
522 data[{0, 2, 0}] = 25;
523 BOOST_TEST( (data[{0, 2, 0}]) == 25);
524 BOOST_TEST(data.at({0, 2, 0}) == 25);
526 BOOST_TEST( (data[{0, 0, 0}]) == 5);
527 BOOST_TEST( (data[{0, 0, 1}]) == 6);
528 BOOST_TEST( (data[{0, 1, 0}]) == 15);
529 BOOST_TEST( (data[{0, 1, 1}]) == 16);
531 data[{0, 2, 1}] = 26;
532 BOOST_TEST( (data[{0, 2, 1}]) == 26);
533 BOOST_TEST(data.at({0, 2, 1}) == 26);
535 BOOST_TEST( (data[{0, 0, 0}]) == 5);
536 BOOST_TEST( (data[{0, 0, 1}]) == 6);
537 BOOST_TEST( (data[{0, 1, 0}]) == 15);
538 BOOST_TEST( (data[{0, 1, 1}]) == 16);
539 BOOST_TEST( (data[{0, 2, 0}]) == 25);
541 data[{1, 0, 0}] = 105;
542 BOOST_TEST( (data[{1, 0, 0}]) == 105);
543 BOOST_TEST(data.at({1, 0, 0}) == 105);
545 BOOST_TEST( (data[{0, 0, 0}]) == 5);
546 BOOST_TEST( (data[{0, 0, 1}]) == 6);
547 BOOST_TEST( (data[{0, 1, 0}]) == 15);
548 BOOST_TEST( (data[{0, 1, 1}]) == 16);
549 BOOST_TEST( (data[{0, 2, 0}]) == 25);
550 BOOST_TEST( (data[{0, 2, 1}]) == 26);
552 data[{1, 0, 1}] = 106;
553 BOOST_TEST( (data[{1, 0, 1}]) == 106);
554 BOOST_TEST(data.at({1, 0, 1}) == 106);
556 BOOST_TEST( (data[{0, 0, 0}]) == 5);
557 BOOST_TEST( (data[{0, 0, 1}]) == 6);
558 BOOST_TEST( (data[{0, 1, 0}]) == 15);
559 BOOST_TEST( (data[{0, 1, 1}]) == 16);
560 BOOST_TEST( (data[{0, 2, 0}]) == 25);
561 BOOST_TEST( (data[{0, 2, 1}]) == 26);
562 BOOST_TEST( (data[{1, 0, 0}]) == 105);
564 data[{1, 1, 0}] = 115;
565 BOOST_TEST( (data[{1, 1, 0}]) == 115);
566 BOOST_TEST(data.at({1, 1, 0}) == 115);
568 BOOST_TEST( (data[{0, 0, 0}]) == 5);
569 BOOST_TEST( (data[{0, 0, 1}]) == 6);
570 BOOST_TEST( (data[{0, 1, 0}]) == 15);
571 BOOST_TEST( (data[{0, 1, 1}]) == 16);
572 BOOST_TEST( (data[{0, 2, 0}]) == 25);
573 BOOST_TEST( (data[{0, 2, 1}]) == 26);
574 BOOST_TEST( (data[{1, 0, 0}]) == 105);
575 BOOST_TEST( (data[{1, 0, 1}]) == 106);
577 data[{1, 1, 1}] = 116;
578 BOOST_TEST( (data[{1, 1, 1}]) == 116);
579 BOOST_TEST(data.at({1, 1, 1}) == 116);
581 BOOST_TEST( (data[{0, 0, 0}]) == 5);
582 BOOST_TEST( (data[{0, 0, 1}]) == 6);
583 BOOST_TEST( (data[{0, 1, 0}]) == 15);
584 BOOST_TEST( (data[{0, 1, 1}]) == 16);
585 BOOST_TEST( (data[{0, 2, 0}]) == 25);
586 BOOST_TEST( (data[{0, 2, 1}]) == 26);
587 BOOST_TEST( (data[{1, 0, 0}]) == 105);
588 BOOST_TEST( (data[{1, 0, 1}]) == 106);
589 BOOST_TEST( (data[{1, 1, 0}]) == 115);
591 data[{1, 2, 0}] = 125;
592 BOOST_TEST( (data[{1, 2, 0}]) == 125);
593 BOOST_TEST(data.at({1, 2, 0}) == 125);
595 BOOST_TEST((data[{0, 0, 0}]) == 5);
596 BOOST_TEST((data[{0, 0, 1}]) == 6);
597 BOOST_TEST((data[{0, 1, 0}]) == 15);
598 BOOST_TEST((data[{0, 1, 1}]) == 16);
599 BOOST_TEST((data[{0, 2, 0}]) == 25);
600 BOOST_TEST((data[{0, 2, 1}]) == 26);
601 BOOST_TEST((data[{1, 0, 0}]) == 105);
602 BOOST_TEST((data[{1, 0, 1}]) == 106);
603 BOOST_TEST((data[{1, 1, 0}]) == 115);
604 BOOST_TEST((data[{1, 1, 1}]) == 116);
606 data[{1, 2, 1}] = 126;
607 BOOST_TEST( (data[{1, 2, 1}]) == 126);
608 BOOST_TEST(data.at({1, 2, 1}) == 126);
610 BOOST_TEST((data[{0, 0, 0}]) == 5);
611 BOOST_TEST((data[{0, 0, 1}]) == 6);
612 BOOST_TEST((data[{0, 1, 0}]) == 15);
613 BOOST_TEST((data[{0, 1, 1}]) == 16);
614 BOOST_TEST((data[{0, 2, 0}]) == 25);
615 BOOST_TEST((data[{0, 2, 1}]) == 26);
616 BOOST_TEST((data[{1, 0, 0}]) == 105);
617 BOOST_TEST((data[{1, 0, 1}]) == 106);
618 BOOST_TEST((data[{1, 1, 0}]) == 115);
619 BOOST_TEST((data[{1, 1, 1}]) == 116);
620 BOOST_TEST((data[{1, 2, 0}]) == 125);
623 BOOST_CHECK_THROW(data.at({0, 3, 0}), std::out_of_range);
624 BOOST_CHECK_THROW(data.at({0, 4, 0}), std::out_of_range);
625 BOOST_CHECK_THROW(data.at({1, 3, 0}), std::out_of_range);
626 BOOST_CHECK_THROW(data.at({1, 4, 0}), std::out_of_range);
627 BOOST_CHECK_THROW(data.at({2, 0, 0}), std::out_of_range);
628 BOOST_CHECK_THROW(data.at({2, 1, 0}), std::out_of_range);
629 BOOST_CHECK_THROW(data.at({2, 2, 0}), std::out_of_range);
630 BOOST_CHECK_THROW(data.at({2, 3, 0}), std::out_of_range);
631 BOOST_CHECK_THROW(data.at({2, 4, 0}), std::out_of_range);
632 BOOST_CHECK_THROW(data.at({0, 3, 1}), std::out_of_range);
633 BOOST_CHECK_THROW(data.at({0, 4, 1}), std::out_of_range);
634 BOOST_CHECK_THROW(data.at({1, 3, 1}), std::out_of_range);
635 BOOST_CHECK_THROW(data.at({1, 4, 1}), std::out_of_range);
636 BOOST_CHECK_THROW(data.at({2, 0, 1}), std::out_of_range);
637 BOOST_CHECK_THROW(data.at({2, 1, 1}), std::out_of_range);
638 BOOST_CHECK_THROW(data.at({2, 2, 1}), std::out_of_range);
639 BOOST_CHECK_THROW(data.at({2, 3, 1}), std::out_of_range);
640 BOOST_CHECK_THROW(data.at({2, 4, 1}), std::out_of_range);
641 BOOST_CHECK_THROW(data.at({0, 0, 2}), std::out_of_range);
642 BOOST_CHECK_THROW(data.at({0, 1, 2}), std::out_of_range);
643 BOOST_CHECK_THROW(data.at({0, 2, 2}), std::out_of_range);
644 BOOST_CHECK_THROW(data.at({0, 3, 2}), std::out_of_range);
645 BOOST_CHECK_THROW(data.at({1, 0, 2}), std::out_of_range);
646 BOOST_CHECK_THROW(data.at({1, 1, 2}), std::out_of_range);
647 BOOST_CHECK_THROW(data.at({1, 2, 2}), std::out_of_range);
648 BOOST_CHECK_THROW(data.at({1, 3, 2}), std::out_of_range);
649 BOOST_CHECK_THROW(data.at({2, 0, 2}), std::out_of_range);
650 BOOST_CHECK_THROW(data.at({2, 1, 2}), std::out_of_range);
651 BOOST_CHECK_THROW(data.at({2, 2, 2}), std::out_of_range);
652 BOOST_CHECK_THROW(data.at({2, 3, 2}), std::out_of_range);
654 BOOST_TEST(data.first() == 5);
656 BOOST_TEST((data[{0, 0, 0}]) == -5);
657 BOOST_TEST(data.first() == -5);
660 BOOST_TEST(data.last() == 126);
662 BOOST_TEST((data[{1U, 2U, 1U}]) == -126);
663 BOOST_TEST(data.last() == -126);
666 auto const& constData = data;
668 static_assert(data.dimensions() == 3U);
669 BOOST_TEST(data.dimSize<0U>() == NCryostats);
670 BOOST_TEST(data.dimSize<1U>() == NTPCs);
671 BOOST_TEST(data.dimSize<2U>() == NPlanes);
672 BOOST_TEST(data.dimSize<3U>() == 0U);
675 (std::addressof(constData.first()) == std::addressof(data.first()));
677 (std::addressof(constData.last()) == std::addressof(data.last()));
679 BOOST_TEST((constData[{0, 0, 0}]) == (data[{0, 0, 0}]));
680 BOOST_TEST((constData[{0, 0, 1}]) == (data[{0, 0, 1}]));
681 BOOST_TEST((constData[{0, 1, 0}]) == (data[{0, 1, 0}]));
682 BOOST_TEST((constData[{0, 1, 1}]) == (data[{0, 1, 1}]));
683 BOOST_TEST((constData[{0, 2, 0}]) == (data[{0, 2, 0}]));
684 BOOST_TEST((constData[{0, 2, 1}]) == (data[{0, 2, 1}]));
685 BOOST_TEST((constData[{1, 0, 0}]) == (data[{1, 0, 0}]));
686 BOOST_TEST((constData[{1, 0, 1}]) == (data[{1, 0, 1}]));
687 BOOST_TEST((constData[{1, 1, 0}]) == (data[{1, 1, 0}]));
688 BOOST_TEST((constData[{1, 1, 1}]) == (data[{1, 1, 1}]));
689 BOOST_TEST((constData[{1, 2, 0}]) == (data[{1, 2, 0}]));
690 BOOST_TEST((constData[{1, 2, 1}]) == (data[{1, 2, 1}]));
691 BOOST_TEST(constData.at({0, 0, 0}) == data.at({0, 0, 0}));
692 BOOST_TEST(constData.at({0, 0, 1}) == data.at({0, 0, 1}));
693 BOOST_TEST(constData.at({0, 1, 0}) == data.at({0, 1, 0}));
694 BOOST_TEST(constData.at({0, 1, 1}) == data.at({0, 1, 1}));
695 BOOST_TEST(constData.at({0, 2, 0}) == data.at({0, 2, 0}));
696 BOOST_TEST(constData.at({0, 2, 1}) == data.at({0, 2, 1}));
697 BOOST_TEST(constData.at({1, 0, 0}) == data.at({1, 0, 0}));
698 BOOST_TEST(constData.at({1, 0, 1}) == data.at({1, 0, 1}));
699 BOOST_TEST(constData.at({1, 1, 0}) == data.at({1, 1, 0}));
700 BOOST_TEST(constData.at({1, 1, 1}) == data.at({1, 1, 1}));
701 BOOST_TEST(constData.at({1, 2, 0}) == data.at({1, 2, 0}));
702 BOOST_TEST(constData.at({1, 2, 1}) == data.at({1, 2, 1}));
704 BOOST_CHECK_THROW(constData.at({0, 3, 0}), std::out_of_range);
705 BOOST_CHECK_THROW(constData.at({0, 4, 0}), std::out_of_range);
706 BOOST_CHECK_THROW(constData.at({1, 3, 0}), std::out_of_range);
707 BOOST_CHECK_THROW(constData.at({1, 4, 0}), std::out_of_range);
708 BOOST_CHECK_THROW(constData.at({2, 0, 0}), std::out_of_range);
709 BOOST_CHECK_THROW(constData.at({2, 1, 0}), std::out_of_range);
710 BOOST_CHECK_THROW(constData.at({2, 2, 0}), std::out_of_range);
711 BOOST_CHECK_THROW(constData.at({2, 3, 0}), std::out_of_range);
712 BOOST_CHECK_THROW(constData.at({2, 4, 0}), std::out_of_range);
713 BOOST_CHECK_THROW(constData.at({0, 3, 1}), std::out_of_range);
714 BOOST_CHECK_THROW(constData.at({0, 4, 1}), std::out_of_range);
715 BOOST_CHECK_THROW(constData.at({1, 3, 1}), std::out_of_range);
716 BOOST_CHECK_THROW(constData.at({1, 4, 1}), std::out_of_range);
717 BOOST_CHECK_THROW(constData.at({2, 0, 1}), std::out_of_range);
718 BOOST_CHECK_THROW(constData.at({2, 1, 1}), std::out_of_range);
719 BOOST_CHECK_THROW(constData.at({2, 2, 1}), std::out_of_range);
720 BOOST_CHECK_THROW(constData.at({2, 3, 1}), std::out_of_range);
721 BOOST_CHECK_THROW(constData.at({2, 4, 1}), std::out_of_range);
722 BOOST_CHECK_THROW(constData.at({0, 0, 2}), std::out_of_range);
723 BOOST_CHECK_THROW(constData.at({0, 1, 2}), std::out_of_range);
724 BOOST_CHECK_THROW(constData.at({0, 2, 2}), std::out_of_range);
725 BOOST_CHECK_THROW(constData.at({0, 3, 2}), std::out_of_range);
726 BOOST_CHECK_THROW(constData.at({1, 0, 2}), std::out_of_range);
727 BOOST_CHECK_THROW(constData.at({1, 1, 2}), std::out_of_range);
728 BOOST_CHECK_THROW(constData.at({1, 2, 2}), std::out_of_range);
729 BOOST_CHECK_THROW(constData.at({1, 3, 2}), std::out_of_range);
730 BOOST_CHECK_THROW(constData.at({2, 0, 2}), std::out_of_range);
731 BOOST_CHECK_THROW(constData.at({2, 1, 2}), std::out_of_range);
732 BOOST_CHECK_THROW(constData.at({2, 2, 2}), std::out_of_range);
733 BOOST_CHECK_THROW(constData.at({2, 3, 2}), std::out_of_range);
736 auto const cb = constData.begin();
737 auto const ce = constData.end();
738 BOOST_TEST(static_cast<size_t>(ce - cb) ==
N);
742 for (
auto&
value: constData) {
743 static_assert(std::is_same_v
744 <decltype(
value), std::decay_t<decltype(constData)>::const_reference>
747 geo::PlaneID const expected_ID = constData.mapper().ID(expected_index);
748 BOOST_TEST(
value == constData[expected_ID]);
752 BOOST_TEST(constData.size() == expected_index);
756 for (
auto&& [ ID,
value ]: constData.items()) {
757 static_assert(std::is_same_v<decltype(ID),
geo::PlaneID>);
758 static_assert(std::is_same_v
759 <decltype(
value), std::decay_t<decltype(constData)>::const_reference>
762 geo::PlaneID const expected_ID = constData.mapper().ID(expected_index);
763 BOOST_TEST(ID == expected_ID);
764 BOOST_TEST(
value == constData[expected_ID]);
768 BOOST_TEST(constData.size() == expected_index);
772 for (
auto c: util::counter<unsigned int>(NCryostats))
773 for (
auto t: util::counter<unsigned int>(NTPCs))
774 for (
auto p: util::counter<unsigned int>(NPlanes))
775 BOOST_TEST((data[{ c, t,
p }]) == 14);
777 data.apply([](
int& v){ v *= 2; });
778 for (
auto c: util::counter<unsigned int>(NCryostats))
779 for (
auto t: util::counter<unsigned int>(NTPCs))
780 for (
auto p: util::counter<unsigned int>(NPlanes))
781 BOOST_TEST((data[{ c, t,
p }]) == 28);
784 static_assert(std::is_same_v<decltype(data.apply(summer)),
Summer<int>&>);
786 BOOST_TEST(summer.
get() ==
N * 28);
790 (std::is_same_v<decltype(constData.apply(summer)),
Summer<int>&>);
791 constData.apply(summer);
792 BOOST_TEST(summer.
get() ==
N * 28);
795 BOOST_TEST(summer1.get() ==
N * 28);
798 BOOST_TEST(summer2.get() ==
N * 28);
801 for (
auto c: util::counter<unsigned int>(NCryostats))
802 for (
auto t: util::counter<unsigned int>(NTPCs))
803 for (
auto p: util::counter<unsigned int>(NPlanes))
804 BOOST_TEST((data[{ c, t,
p }]) == 0);
807 BOOST_TEST(data.empty());
812 BOOST_AUTO_TEST_SUITE(geometrydatacontainers_test)
817 constexpr std::size_t NCryostats = 2U;
818 constexpr std::size_t NTPCs = 3U;
830 BOOST_TEST(data2.
empty());
840 constexpr std::size_t NCryostats = 2U;
841 constexpr std::size_t NTPCs = 3U;
842 constexpr std::size_t NPlanes = 2U;
854 BOOST_TEST(data2.
empty());
863 BOOST_AUTO_TEST_SUITE_END()
GeoID firstID() const
Returns the ID of the first element with GeoID type.
void TPCDataContainerTest(geo::TPCDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs)
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
size_type capacity() const
Returns the number of elements the container has memory for.
The data type to uniquely identify a Plane.
void PlaneDataContainerTest(geo::PlaneDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs, std::size_t const NPlanes)
Container with one element per geometry wire plane.
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
Containers to hold one datum per TPC or plane.
Container with one element per geometry TPC.
Test of util::counter and support utilities.
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
static constexpr unsigned int dimensions()
Dimensions of the ID of this container.
Functions to help debugging by instrumenting code.
process_name largeant stream1 can override from command line with o or output physics producers generator N
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
size_type size() const
Returns the number of elements in the container.
bool empty() const
Returns whether the container has no elements (false by assumptions).
void resizeAs(geo::GeoIDdataContainer< OT, Mapper_t > const &other)
Prepares the container with default-constructed data.
unsigned int dimSize() const
Dimensions of the Level dimension of this container.