10 #ifndef GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
11 # define GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS 1
12 #endif // !GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
24 #define BOOST_TEST_MODULE ( geo_types_test )
25 #include "boost/test/unit_test.hpp"
31 #include <type_traits>
35 auto makeConst(T& var) -> decltype(
auto) {
return const_cast<T
const&
>(var); }
37 template <
typename ID>
39 {
return geo::details::geoElementLevel<ID>() == ID::Level; }
45 static_assert(assertGeoIDlevel<geo::CryostatID>());
46 static_assert(assertGeoIDlevel<geo::OpDetID>());
47 static_assert(assertGeoIDlevel<geo::TPCID>());
48 static_assert(assertGeoIDlevel<geo::PlaneID>());
49 static_assert(assertGeoIDlevel<geo::WireID>());
50 static_assert( geo::details::isTopGeoElementID<geo::CryostatID>);
51 static_assert(!geo::details::isTopGeoElementID<geo::OpDetID>);
52 static_assert(!geo::details::isTopGeoElementID<geo::TPCID>);
53 static_assert(!geo::details::isTopGeoElementID<geo::PlaneID>);
54 static_assert(!geo::details::isTopGeoElementID<geo::WireID>);
109 "geo::CryostatID can be implicitly converted to an integral type"
113 "geo::OpDetID can be implicitly converted to an integral type"
117 "geo::TPCID can be implicitly converted to an integral type"
121 "geo::PlaneID can be implicitly converted to an integral type"
125 "geo::WireID can be implicitly converted to an integral type"
135 BOOST_TEST(
id.isValid == answer);
137 BOOST_TEST(!
id == !answer);
139 BOOST_TEST((
bool)
id == answer);
144 bool const orig =
bool(
id);
146 id.setValidity(
true);
147 BOOST_TEST(
bool(
id));
148 id.setValidity(
false);
151 BOOST_TEST(
bool(
id));
154 id.setValidity(orig);
155 BOOST_TEST(
bool(
id) == orig);
160 template <
typename TESTID,
typename REFID = TESTID>
162 BOOST_TEST(!(
id < smaller) );
163 BOOST_TEST(!(
id == smaller) );
164 BOOST_TEST(
id != smaller );
165 BOOST_TEST( smaller <
id );
166 BOOST_TEST(smaller.cmp(
id) < 0);
167 BOOST_TEST(
id.cmp(smaller) > 0);
171 template <
typename TESTID,
typename REFID = TESTID>
173 BOOST_TEST(!(
id < same) );
174 BOOST_TEST(
id == same );
175 BOOST_TEST(!(
id != same) );
176 BOOST_TEST(!(same <
id) );
177 BOOST_TEST(same.cmp(
id) == 0);
178 BOOST_TEST(
id.cmp(same) == 0);
182 template <
typename TESTID>
187 template <
typename TESTID,
typename REFID = TESTID>
189 BOOST_TEST(
id < larger );
190 BOOST_TEST(
id != larger );
191 BOOST_TEST(!(
id == larger) );
192 BOOST_TEST(!(larger <
id) );
193 BOOST_TEST(larger.cmp(
id) > 0);
194 BOOST_TEST(
id.cmp(larger) < 0);
199 template <
typename TESTID,
typename REFID = TESTID>
202 REFID
const& smaller,
216 BOOST_TEST_MESSAGE(
"Testing default-constructed cryostat ID");
238 BOOST_TEST_CHECKPOINT(
"Testing cryostat ID constructed with an integer");
256 BOOST_TEST(cid.
getIndex<0U>() == 1);
258 BOOST_TEST(cid.
getIndex<0U>() == 2);
262 BOOST_TEST_CHECKPOINT(
"Testing cryostat ID constructed with an integer 0");
281 BOOST_TEST_CHECKPOINT(
"Testing default-constructed optical detector ID");
297 BOOST_TEST_CHECKPOINT(
"Testing integral-constructed optical detector ID");
299 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
300 BOOST_TEST_MESSAGE(
" (test skipped)");
304 BOOST_TEST_MESSAGE(
"OpDetID(1) = " << std::string(oid));
308 BOOST_TEST_MESSAGE(
"int(OpDetID(1)) = " << what);
310 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
317 BOOST_TEST_CHECKPOINT(
"Testing ID-constructed optical detector ID");
332 BOOST_TEST_CHECKPOINT(
"Testing comparison with optical detector ID");
334 larger_oid(cid, oid.
OpDet + 1);
343 BOOST_TEST_CHECKPOINT(
"Testing optical detector ID constructed with indices");
351 BOOST_TEST_CHECKPOINT(
"Testing comparison with same cryostat ID");
353 geo::OpDetID smaller_oid(1, 14), same_oid(1, 15), larger_oid(1, 16);
356 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID");
362 BOOST_TEST(oid.
getIndex<0U>() == 1);
364 BOOST_TEST(oid.
getIndex<0U>() == 2);
366 BOOST_TEST(oid.
getIndex<1U>() == 15);
368 BOOST_TEST(oid.
getIndex<1U>() == 19);
371 BOOST_TEST_CHECKPOINT
372 (
"Testing optical detector ID constructed with OpDet #0");
393 BOOST_TEST_CHECKPOINT(
"Testing default-constructed TPC ID");
409 BOOST_TEST_CHECKPOINT(
"Testing integral-constructed TPC ID");
411 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
412 BOOST_TEST_MESSAGE(
" (test skipped)");
416 BOOST_TEST_MESSAGE(
"TPCID(1) = " << std::string(tid));
420 BOOST_TEST_MESSAGE(
"int(TPCID(1)) = " << what);
422 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
429 BOOST_TEST_CHECKPOINT(
"Testing ID-constructed TPC ID");
444 BOOST_TEST_CHECKPOINT(
"Testing comparison with TPC ID");
446 larger_tid(cid, tid.
TPC + 1);
455 BOOST_TEST_CHECKPOINT(
"Testing TPC ID constructed with indices");
463 BOOST_TEST_CHECKPOINT(
"Testing comparison with same cryostat ID");
465 geo::TPCID smaller_tid(1, 14), same_tid(1, 15), larger_tid(1, 16);
468 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID");
469 geo::TPCID smaller_cid(0, 16), larger_cid(2, 14);
474 BOOST_TEST_CHECKPOINT(
"Testing TPC ID constructed with a TPC #0");
477 BOOST_TEST(tid.
getIndex<0U>() == 1);
479 BOOST_TEST(tid.
getIndex<0U>() == 2);
481 BOOST_TEST(tid.
getIndex<1U>() == 15);
483 BOOST_TEST(tid.
getIndex<1U>() == 19);
505 BOOST_TEST_CHECKPOINT(
"Testing default-constructed plane ID");
521 BOOST_TEST_CHECKPOINT(
"Testing integral-constructed plane ID");
523 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
524 BOOST_TEST_MESSAGE(
" (test skipped)");
528 BOOST_TEST_MESSAGE(
"PlaneID(1) = " << std::string(pid));
532 BOOST_TEST_MESSAGE(
"int(PlaneID(1)) = " << what);
534 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
541 BOOST_TEST_CHECKPOINT(
"Testing ID-constructed plane ID");
556 BOOST_TEST_CHECKPOINT(
"Testing comparison with plane ID");
558 larger_pid(tid, pid.
Plane + 1);
567 BOOST_TEST_CHECKPOINT(
"Testing plane ID constructed with indices");
580 BOOST_TEST_CHECKPOINT(
"Testing comparison with same TPC ID");
583 smaller_pid(1, 15, 31), same_pid(1, 15, 32), larger_pid(1, 15, 33);
586 BOOST_TEST_CHECKPOINT(
"Testing comparison with different TPC ID (1)");
587 geo::PlaneID smaller_tid1(1, 14, 33), larger_tid1(1, 16, 31);
590 BOOST_TEST_CHECKPOINT(
"Testing comparison with different TPC ID (2)");
591 geo::PlaneID smaller_tid2(1, 14, 32), larger_tid2(1, 16, 32);
595 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID");
596 geo::PlaneID smaller_cid1(0, 15, 33), larger_cid1(2, 15, 31);
599 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID (2)");
600 geo::PlaneID smaller_cid2(0, 15, 32), larger_cid2(2, 15, 32);
605 BOOST_TEST(pid.
getIndex<0U>() == 1);
607 BOOST_TEST(pid.
getIndex<0U>() == 2);
609 BOOST_TEST(pid.
getIndex<1U>() == 15);
611 BOOST_TEST(pid.
getIndex<1U>() == 19);
613 BOOST_TEST(pid.
getIndex<2U>() == 32);
615 BOOST_TEST(pid.
getIndex<2U>() == 76);
619 BOOST_TEST_CHECKPOINT(
"Testing plane ID constructed with a plane #0");
640 BOOST_TEST_CHECKPOINT(
"Testing default-constructed wire ID");
656 BOOST_TEST_CHECKPOINT(
"Testing integral-constructed wire ID");
658 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
659 BOOST_TEST_MESSAGE(
" (test skipped)");
663 BOOST_TEST_MESSAGE(
"WireID(1) = " << std::string(wid));
667 BOOST_TEST_MESSAGE(
"int(WireID(1)) = " << what);
669 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
675 BOOST_TEST_CHECKPOINT(
"Testing ID-constructed wire ID");
692 BOOST_TEST_CHECKPOINT(
"Testing comparison with wire ID");
694 larger_wid(pid, wid.
Wire + 1);
703 BOOST_TEST_CHECKPOINT(
"Testing wire ID constructed with indices");
717 BOOST_TEST_CHECKPOINT(
"Testing comparison with same TPC ID");
720 smaller_wid(1, 15, 32, 26), same_wid(1, 15, 32, 27),
721 larger_wid(1, 15, 32, 28);
724 BOOST_TEST_CHECKPOINT(
"Testing comparison with different plane ID (1)");
725 geo::WireID smaller_pid1(1, 15, 31, 28), larger_pid1(1, 15, 33, 26);
728 BOOST_TEST_CHECKPOINT(
"Testing comparison with different plane ID (2)");
729 geo::WireID smaller_pid2(1, 15, 31, 27), larger_pid2(1, 15, 33, 27);
733 BOOST_TEST_CHECKPOINT(
"Testing comparison with different TPC ID (1)");
734 geo::WireID smaller_tid1(1, 14, 32, 28), larger_tid1(1, 16, 32, 26);
737 BOOST_TEST_CHECKPOINT(
"Testing comparison with different TPC ID (2)");
738 geo::WireID smaller_tid2(1, 14, 32, 27), larger_tid2(1, 16, 32, 27);
742 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID");
743 geo::WireID smaller_cid1(0, 15, 32, 28), larger_cid1(2, 15, 32, 26);
746 BOOST_TEST_CHECKPOINT(
"Testing comparison with different cryostat ID (2)");
747 geo::WireID smaller_cid2(0, 15, 32, 27), larger_cid2(2, 15, 32, 27);
752 BOOST_TEST_CHECKPOINT(
"Testing wire ID constructed with a wire #0");
755 BOOST_TEST(wid.
getIndex<0U>() == 1);
757 BOOST_TEST(wid.
getIndex<0U>() == 2);
759 BOOST_TEST(wid.
getIndex<1U>() == 15);
761 BOOST_TEST(wid.
getIndex<1U>() == 19);
763 BOOST_TEST(wid.
getIndex<2U>() == 32);
765 BOOST_TEST(wid.
getIndex<2U>() == 76);
767 BOOST_TEST(wid.
getIndex<3U>() == 27);
769 BOOST_TEST(wid.
getIndex<3U>() == 45);
void test_OpDetID_defaultConstructor()
void test_TPCID_defaultConstructor()
constexpr auto getIndex() const
Returns the index level Index of this type.
void test_OpDetID_integralConstructor()
void TestCompareSelfID(TESTID const &id)
Test comparison operators.
constexpr auto getIndex() const
Returns the index level Index of this type.
void test_TPCID_nestedConstructor()
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
auto & writeIndex()
Returns the index level Index of this type.
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
auto & writeIndex()
Returns the index level Index of this type.
void TestCompareSameID(TESTID const &id, REFID const &same)
Test comparison operators.
void test_TPCID_directConstructor()
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
void test_OpDetID_nestedConstructor()
unsigned int PlaneID_t
Type for the ID number.
The data type to uniquely identify a Plane.
void test_PlaneID_directConstructor()
void test_WireID_defaultConstructor()
void test_PlaneID_integralConstructor()
constexpr auto getIndex() const
Returns the index level Index of this type.
CryostatID_t Cryostat
Index of cryostat.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (plane's).
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
WireID_t Wire
Index of the wire within its plane.
auto makeConst(T &var) -> decltype(auto)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (wire's).
void TestIDvalidity(geo::CryostatID const &id, bool answer)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (OpDet's).
void TestSetIDvalidity(geo::CryostatID &id)
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
OpDetID_t OpDet
Index of the optical detector within its cryostat.
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
void test_WireID_directConstructor()
void test_OpDetID_directConstructor()
void test_PlaneID_nestedConstructor()
auto & writeIndex()
Returns the index level Index of this type.
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
constexpr auto getIndex() const
Returns the index level Index of this type.
void test_WireID_nestedConstructor()
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
Definition of data types for geometry description.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
void test_TPCID_integralConstructor()
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
void test_CryostatID_directConstructor()
void test_WireID_integralConstructor()
void test_CryostatID_defaultConstructor()
auto & writeIndex()
Returns the index level Index of this type.
unsigned int CryostatID_t
Type for the ID number.
unsigned int OpDetID_t
Type for the ID number.
unsigned int TPCID_t
Type for the ID number.
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (TPC's).
unsigned int WireID_t
Type for the ID number.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
constexpr bool assertGeoIDlevel()
TPCID_t TPC
Index of the TPC within its cryostat.
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
auto & writeIndex()
Returns the index level Index of this type.
The data type to uniquely identify a optical detector.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
void test_PlaneID_defaultConstructor()
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
constexpr auto getIndex() const
Returns the index level Index of this type.
The data type to uniquely identify a cryostat.
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (cryostat's).