All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
geo_types_test.cc File Reference

Test of geo_types.h types. More...

#include "boost/test/unit_test.hpp"
#include "larcoreobj/SimpleTypesAndConstants/geo_types.h"
#include <type_traits>

Go to the source code of this file.

Macros

#define GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS   1
 
#define BOOST_TEST_MODULE   ( geo_types_test )
 

Functions

template<typename T >
auto makeConst (T &var) -> decltype(auto)
 
template<typename ID >
constexpr bool assertGeoIDlevel ()
 
void TestIDvalidity (geo::CryostatID const &id, bool answer)
 
void TestSetIDvalidity (geo::CryostatID &id)
 
template<typename TESTID , typename REFID = TESTID>
void TestCompareSmallerID (TESTID const &id, REFID const &smaller)
 Test comparison operators. More...
 
template<typename TESTID , typename REFID = TESTID>
void TestCompareSameID (TESTID const &id, REFID const &same)
 Test comparison operators. More...
 
template<typename TESTID >
void TestCompareSelfID (TESTID const &id)
 Test comparison operators. More...
 
template<typename TESTID , typename REFID = TESTID>
void TestCompareLargerID (TESTID const &id, REFID const &larger)
 Test comparison operators. More...
 
template<typename TESTID , typename REFID = TESTID>
void TestIDcomparison (TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
 Test comparison operators. More...
 
void test_CryostatID_defaultConstructor ()
 
void test_CryostatID_directConstructor ()
 
void test_OpDetID_defaultConstructor ()
 
void test_OpDetID_integralConstructor ()
 
void test_OpDetID_nestedConstructor ()
 
void test_OpDetID_directConstructor ()
 
void test_TPCID_defaultConstructor ()
 
void test_TPCID_integralConstructor ()
 
void test_TPCID_nestedConstructor ()
 
void test_TPCID_directConstructor ()
 
void test_PlaneID_defaultConstructor ()
 
void test_PlaneID_integralConstructor ()
 
void test_PlaneID_nestedConstructor ()
 
void test_PlaneID_directConstructor ()
 
void test_WireID_defaultConstructor ()
 
void test_WireID_integralConstructor ()
 
void test_WireID_nestedConstructor ()
 
void test_WireID_directConstructor ()
 
 BOOST_AUTO_TEST_CASE (CryostatIDtest)
 
 BOOST_AUTO_TEST_CASE (OpDetIDtest)
 
 BOOST_AUTO_TEST_CASE (TPCIDtest)
 
 BOOST_AUTO_TEST_CASE (PlaneIDtest)
 
 BOOST_AUTO_TEST_CASE (WireIDtest)
 

Detailed Description

Test of geo_types.h types.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
May 5th, 2015

Definition in file geo_types_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( geo_types_test )

Definition at line 24 of file geo_types_test.cc.

#define GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS   1

Definition at line 11 of file geo_types_test.cc.

Function Documentation

template<typename ID >
constexpr bool assertGeoIDlevel ( )

Definition at line 38 of file geo_types_test.cc.

39  { return geo::details::geoElementLevel<ID>() == ID::Level; }
BOOST_AUTO_TEST_CASE ( CryostatIDtest  )

Definition at line 791 of file geo_types_test.cc.

791  {
794 }
void test_CryostatID_directConstructor()
void test_CryostatID_defaultConstructor()
BOOST_AUTO_TEST_CASE ( OpDetIDtest  )

Definition at line 799 of file geo_types_test.cc.

799  {
804 }
void test_OpDetID_defaultConstructor()
void test_OpDetID_integralConstructor()
void test_OpDetID_nestedConstructor()
void test_OpDetID_directConstructor()
BOOST_AUTO_TEST_CASE ( TPCIDtest  )

Definition at line 809 of file geo_types_test.cc.

809  {
814 }
void test_TPCID_defaultConstructor()
void test_TPCID_nestedConstructor()
void test_TPCID_directConstructor()
void test_TPCID_integralConstructor()
BOOST_AUTO_TEST_CASE ( PlaneIDtest  )

Definition at line 819 of file geo_types_test.cc.

819  {
824 }
void test_PlaneID_directConstructor()
void test_PlaneID_integralConstructor()
void test_PlaneID_nestedConstructor()
void test_PlaneID_defaultConstructor()
BOOST_AUTO_TEST_CASE ( WireIDtest  )

Definition at line 829 of file geo_types_test.cc.

829  {
834 }
void test_WireID_defaultConstructor()
void test_WireID_directConstructor()
void test_WireID_nestedConstructor()
void test_WireID_integralConstructor()
template<typename T >
auto makeConst ( T &  var) -> decltype(auto)

Definition at line 35 of file geo_types_test.cc.

35 { return const_cast<T const&>(var); }
void test_CryostatID_defaultConstructor ( )

Definition at line 214 of file geo_types_test.cc.

214  {
215 
216  BOOST_TEST_MESSAGE("Testing default-constructed cryostat ID");
217 
218  geo::CryostatID cid;
219 
220  // a default-constructed ID is invalid:
221  TestIDvalidity(cid, false);
222  TestSetIDvalidity(cid);
223 
224 /* // feature not added
225  // test assignment from ID_t
226  cid = 1;
227  BOOST_TEST(cid.Cryostat == 1);
228 */
229 
230  BOOST_TEST(&cid.deepestIndex() == &cid.Cryostat);
231  BOOST_TEST(&makeConst(cid).deepestIndex() == &cid.Cryostat);
232 
233 } // test_CryostatID_defaultConstructor()
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
auto makeConst(T &var) -> decltype(auto)
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (cryostat&#39;s).
Definition: geo_types.h:253
void test_CryostatID_directConstructor ( )

Definition at line 236 of file geo_types_test.cc.

236  {
237 
238  BOOST_TEST_CHECKPOINT("Testing cryostat ID constructed with an integer");
239 
240  geo::CryostatID cid(1);
241 
242  // an explicitly constructed ID is valid:
243  TestIDvalidity(cid, true);
244  TestSetIDvalidity(cid);
245 
246  // check the ID value
247  BOOST_TEST(cid.Cryostat == geo::CryostatID::CryostatID_t(1));
248 
249  // test comparison operators
250  // (exercise copy constructor too)
251  geo::CryostatID smaller_cid(0), same_cid(cid), larger_cid(2);
252 
253  TestIDcomparison(cid, smaller_cid, same_cid, larger_cid);
254 
255  // test setting and accessing a single index
256  BOOST_TEST(cid.getIndex<0U>() == 1);
257  cid.writeIndex<0U>() = 2;
258  BOOST_TEST(cid.getIndex<0U>() == 2);
259 
260 
261  // make sure the ID with cryostat 0 is fine (it's not a bad ID!)
262  BOOST_TEST_CHECKPOINT("Testing cryostat ID constructed with an integer 0");
263 
264  geo::CryostatID first_cid(0);
265  TestIDvalidity(cid, true);
266  TestSetIDvalidity(cid);
267 
268  // check the ID value
269  BOOST_TEST(first_cid.Cryostat == geo::CryostatID::CryostatID_t(0));
270 
271 } // test_CryostatID_directConstructor()
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_OpDetID_defaultConstructor ( )

Definition at line 279 of file geo_types_test.cc.

279  {
280 
281  BOOST_TEST_CHECKPOINT("Testing default-constructed optical detector ID");
282 
283  geo::OpDetID oid;
284 
285  // a default-constructed ID is invalid:
286  TestIDvalidity(oid, false);
287  TestSetIDvalidity(oid);
288 
289  BOOST_TEST(&oid.deepestIndex() == &oid.OpDet);
290  BOOST_TEST(&makeConst(oid).deepestIndex() == &oid.OpDet);
291 
292 } // test_OpDetID_defaultConstructor()
auto makeConst(T &var) -> decltype(auto)
void TestIDvalidity(geo::CryostatID const &id, bool answer)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (OpDet&#39;s).
Definition: geo_types.h:342
void TestSetIDvalidity(geo::CryostatID &id)
OpDetID_t OpDet
Index of the optical detector within its cryostat.
Definition: geo_types.h:319
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
void test_OpDetID_directConstructor ( )

Definition at line 341 of file geo_types_test.cc.

341  {
342 
343  BOOST_TEST_CHECKPOINT("Testing optical detector ID constructed with indices");
344 
345  geo::OpDetID oid(1, 15);
346 
347  // an explicitly constructed ID is valid:
348  TestIDvalidity(oid, true);
349  TestSetIDvalidity(oid);
350 
351  BOOST_TEST_CHECKPOINT("Testing comparison with same cryostat ID");
352 
353  geo::OpDetID smaller_oid(1, 14), same_oid(1, 15), larger_oid(1, 16);
354  TestIDcomparison(oid, smaller_oid, same_oid, larger_oid);
355 
356  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
357  geo::OpDetID smaller_cid(0, 16), larger_cid(2, 14);
358  TestCompareSmallerID(oid, smaller_cid);
359  TestCompareLargerID(oid, larger_cid);
360 
361  // test setting and accessing a single index
362  BOOST_TEST(oid.getIndex<0U>() == 1);
363  oid.writeIndex<0U>() = 2;
364  BOOST_TEST(oid.getIndex<0U>() == 2);
365 
366  BOOST_TEST(oid.getIndex<1U>() == 15);
367  oid.writeIndex<1U>() = 19;
368  BOOST_TEST(oid.getIndex<1U>() == 19);
369 
370  // make sure the ID with optical detector 0 is fine (it's not a bad ID!)
371  BOOST_TEST_CHECKPOINT
372  ("Testing optical detector ID constructed with OpDet #0");
373 
374  geo::OpDetID first_oid(0, 0);
375  TestIDvalidity(first_oid, true);
376  TestSetIDvalidity(first_oid);
377 
378  // - check the ID value
379  BOOST_TEST(first_oid.Cryostat == geo::CryostatID::CryostatID_t(0));
380  BOOST_TEST(first_oid.OpDet == geo::OpDetID::OpDetID_t(0));
381 
382 
383 } // test_OpDetID_directConstructor()
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int OpDetID_t
Type for the ID number.
Definition: geo_types.h:298
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_OpDetID_integralConstructor ( )

Definition at line 295 of file geo_types_test.cc.

295  {
296 
297  BOOST_TEST_CHECKPOINT("Testing integral-constructed optical detector ID");
298 
299 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
300  BOOST_TEST_MESSAGE(" (test skipped)");
301 #else
302  geo::OpDetID oid(1);
303 
304  BOOST_TEST_MESSAGE("OpDetID(1) = " << std::string(oid));
305 
306  geo::OpDetID::OpDetID_t what = oid;
307 
308  BOOST_TEST_MESSAGE("int(OpDetID(1)) = " << what);
309 
310 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
311 
312 } // test_OpDetID_integralConstructor()
unsigned int OpDetID_t
Type for the ID number.
Definition: geo_types.h:298
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
void test_OpDetID_nestedConstructor ( )

Definition at line 315 of file geo_types_test.cc.

315  {
316 
317  BOOST_TEST_CHECKPOINT("Testing ID-constructed optical detector ID");
318 
319  geo::CryostatID cid(1);
320  geo::OpDetID oid(cid, 15);
321 
322  // an explicitly constructed ID is valid:
323  TestIDvalidity(oid, true);
324  TestSetIDvalidity(oid);
325 
326  // check the ID value
327  BOOST_TEST(oid.Cryostat == geo::CryostatID::CryostatID_t( 1));
328  BOOST_TEST(oid.OpDet == geo::OpDetID::OpDetID_t(15));
329 
330  // test comparison operators (exercise copy constructor too)
331  // - with optical detector ID
332  BOOST_TEST_CHECKPOINT("Testing comparison with optical detector ID");
333  geo::OpDetID smaller_oid(cid, oid.OpDet - 1), same_oid(oid),
334  larger_oid(cid, oid.OpDet + 1);
335 
336  TestIDcomparison(oid, smaller_oid, same_oid, larger_oid);
337 
338 } // test_OpDetID_nestedConstructor()
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int OpDetID_t
Type for the ID number.
Definition: geo_types.h:298
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_PlaneID_defaultConstructor ( )

Definition at line 503 of file geo_types_test.cc.

503  {
504 
505  BOOST_TEST_CHECKPOINT("Testing default-constructed plane ID");
506 
507  geo::PlaneID pid;
508 
509  // a default-constructed ID is invalid:
510  TestIDvalidity(pid, false);
511  TestSetIDvalidity(pid);
512 
513  BOOST_TEST(&pid.deepestIndex() == &pid.Plane);
514  BOOST_TEST(&makeConst(pid).deepestIndex() == &pid.Plane);
515 
516 } // test_PlaneID_defaultConstructor()
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (plane&#39;s).
Definition: geo_types.h:516
auto makeConst(T &var) -> decltype(auto)
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
void test_PlaneID_directConstructor ( )

Definition at line 565 of file geo_types_test.cc.

565  {
566 
567  BOOST_TEST_CHECKPOINT("Testing plane ID constructed with indices");
568 
569  geo::PlaneID pid(1, 15, 32);
570 
571  // an explicitly constructed ID is valid:
572  TestIDvalidity(pid, true);
573  TestSetIDvalidity(pid);
574 
575  // check the ID value
576  BOOST_TEST(pid.Cryostat == geo::CryostatID::CryostatID_t( 1));
577  BOOST_TEST(pid.TPC == geo::TPCID::TPCID_t(15));
578  BOOST_TEST(pid.Plane == geo::PlaneID::PlaneID_t(32));
579 
580  BOOST_TEST_CHECKPOINT("Testing comparison with same TPC ID");
581 
583  smaller_pid(1, 15, 31), same_pid(1, 15, 32), larger_pid(1, 15, 33);
584  TestIDcomparison(pid, smaller_pid, same_pid, larger_pid);
585 
586  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (1)");
587  geo::PlaneID smaller_tid1(1, 14, 33), larger_tid1(1, 16, 31);
588  TestCompareSmallerID(pid, smaller_tid1);
589  TestCompareLargerID(pid, larger_tid1);
590  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (2)");
591  geo::PlaneID smaller_tid2(1, 14, 32), larger_tid2(1, 16, 32);
592  TestCompareSmallerID(pid, smaller_tid2);
593  TestCompareLargerID(pid, larger_tid2);
594 
595  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
596  geo::PlaneID smaller_cid1(0, 15, 33), larger_cid1(2, 15, 31);
597  TestCompareSmallerID(pid, smaller_cid1);
598  TestCompareLargerID(pid, larger_cid1);
599  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID (2)");
600  geo::PlaneID smaller_cid2(0, 15, 32), larger_cid2(2, 15, 32);
601  TestCompareSmallerID(pid, smaller_cid2);
602  TestCompareLargerID(pid, larger_cid2);
603 
604  // test setting and accessing a single index
605  BOOST_TEST(pid.getIndex<0U>() == 1);
606  pid.writeIndex<0U>() = 2;
607  BOOST_TEST(pid.getIndex<0U>() == 2);
608 
609  BOOST_TEST(pid.getIndex<1U>() == 15);
610  pid.writeIndex<1U>() = 19;
611  BOOST_TEST(pid.getIndex<1U>() == 19);
612 
613  BOOST_TEST(pid.getIndex<2U>() == 32);
614  pid.writeIndex<2U>() = 76;
615  BOOST_TEST(pid.getIndex<2U>() == 76);
616 
617 
618  // make sure the ID with plane 0 is fine (it's not a bad ID!)
619  BOOST_TEST_CHECKPOINT("Testing plane ID constructed with a plane #0");
620 
621  geo::PlaneID first_pid(0, 0, 0);
622  TestIDvalidity(first_pid, true);
623  TestSetIDvalidity(first_pid);
624 
625  // - check the ID value
626  BOOST_TEST(first_pid.Cryostat == geo::CryostatID::CryostatID_t(0));
627  BOOST_TEST(first_pid.TPC == geo::TPCID::TPCID_t(0));
628  BOOST_TEST(first_pid.Plane == geo::PlaneID::PlaneID_t(0));
629 
630 } // test_PlaneID_directConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_PlaneID_integralConstructor ( )

Definition at line 519 of file geo_types_test.cc.

519  {
520 
521  BOOST_TEST_CHECKPOINT("Testing integral-constructed plane ID");
522 
523 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
524  BOOST_TEST_MESSAGE(" (test skipped)");
525 #else
526  geo::PlaneID pid(1);
527 
528  BOOST_TEST_MESSAGE("PlaneID(1) = " << std::string(pid));
529 
530  geo::PlaneID::PlaneID_t what = pid;
531 
532  BOOST_TEST_MESSAGE("int(PlaneID(1)) = " << what);
533 
534 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
535 
536 } // test_PlaneID_integralConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
void test_PlaneID_nestedConstructor ( )

Definition at line 539 of file geo_types_test.cc.

539  {
540 
541  BOOST_TEST_CHECKPOINT("Testing ID-constructed plane ID");
542 
543  geo::TPCID tid(1, 15);
544  geo::PlaneID pid(tid, 32);
545 
546  // an explicitly constructed ID is valid:
547  TestIDvalidity(pid, true);
548  TestSetIDvalidity(pid);
549 
550  // check the ID value
551  BOOST_TEST(pid.Cryostat == geo::CryostatID::CryostatID_t( 1));
552  BOOST_TEST(pid.TPC == geo::TPCID::TPCID_t(15));
553  BOOST_TEST(pid.Plane == geo::PlaneID::PlaneID_t(32));
554 
555  // test comparison operators (exercise copy constructor too)
556  BOOST_TEST_CHECKPOINT("Testing comparison with plane ID");
557  geo::PlaneID smaller_pid(tid, pid.Plane - 1), same_pid(pid),
558  larger_pid(tid, pid.Plane + 1);
559 
560  TestIDcomparison(pid, smaller_pid, same_pid, larger_pid);
561 
562 } // test_PlaneID_nestedConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_TPCID_defaultConstructor ( )

Definition at line 391 of file geo_types_test.cc.

391  {
392 
393  BOOST_TEST_CHECKPOINT("Testing default-constructed TPC ID");
394 
395  geo::TPCID tid;
396 
397  // a default-constructed ID is invalid:
398  TestIDvalidity(tid, false);
399  TestSetIDvalidity(tid);
400 
401  BOOST_TEST(&tid.deepestIndex() == &tid.TPC);
402  BOOST_TEST(&makeConst(tid).deepestIndex() == &tid.TPC);
403 
404 } // test_TPCID_defaultConstructor()
auto makeConst(T &var) -> decltype(auto)
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (TPC&#39;s).
Definition: geo_types.h:428
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
void test_TPCID_directConstructor ( )

Definition at line 453 of file geo_types_test.cc.

453  {
454 
455  BOOST_TEST_CHECKPOINT("Testing TPC ID constructed with indices");
456 
457  geo::TPCID tid(1, 15);
458 
459  // an explicitly constructed ID is valid:
460  TestIDvalidity(tid, true);
461  TestSetIDvalidity(tid);
462 
463  BOOST_TEST_CHECKPOINT("Testing comparison with same cryostat ID");
464 
465  geo::TPCID smaller_tid(1, 14), same_tid(1, 15), larger_tid(1, 16);
466  TestIDcomparison(tid, smaller_tid, same_tid, larger_tid);
467 
468  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
469  geo::TPCID smaller_cid(0, 16), larger_cid(2, 14);
470  TestCompareSmallerID(tid, smaller_cid);
471  TestCompareLargerID(tid, larger_cid);
472 
473  // make sure the ID with TPC 0 is fine (it's not a bad ID!)
474  BOOST_TEST_CHECKPOINT("Testing TPC ID constructed with a TPC #0");
475 
476  // test setting and accessing a single index
477  BOOST_TEST(tid.getIndex<0U>() == 1);
478  tid.writeIndex<0U>() = 2;
479  BOOST_TEST(tid.getIndex<0U>() == 2);
480 
481  BOOST_TEST(tid.getIndex<1U>() == 15);
482  tid.writeIndex<1U>() = 19;
483  BOOST_TEST(tid.getIndex<1U>() == 19);
484 
485 
486  geo::TPCID first_tid(0, 0);
487  TestIDvalidity(first_tid, true);
488  TestSetIDvalidity(first_tid);
489 
490  // - check the ID value
491  BOOST_TEST(first_tid.Cryostat == geo::CryostatID::CryostatID_t(0));
492  BOOST_TEST(first_tid.TPC == geo::TPCID::TPCID_t(0));
493 
494 
495 } // test_TPCID_directConstructor()
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_TPCID_integralConstructor ( )

Definition at line 407 of file geo_types_test.cc.

407  {
408 
409  BOOST_TEST_CHECKPOINT("Testing integral-constructed TPC ID");
410 
411 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
412  BOOST_TEST_MESSAGE(" (test skipped)");
413 #else
414  geo::TPCID tid(1);
415 
416  BOOST_TEST_MESSAGE("TPCID(1) = " << std::string(tid));
417 
418  geo::TPCID::TPCID_t what = tid;
419 
420  BOOST_TEST_MESSAGE("int(TPCID(1)) = " << what);
421 
422 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
423 
424 } // test_TPCID_integralConstructor()
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void test_TPCID_nestedConstructor ( )

Definition at line 427 of file geo_types_test.cc.

427  {
428 
429  BOOST_TEST_CHECKPOINT("Testing ID-constructed TPC ID");
430 
431  geo::CryostatID cid(1);
432  geo::TPCID tid(cid, 15);
433 
434  // an explicitly constructed ID is valid:
435  TestIDvalidity(tid, true);
436  TestSetIDvalidity(tid);
437 
438  // check the ID value
439  BOOST_TEST(tid.Cryostat == geo::CryostatID::CryostatID_t( 1));
440  BOOST_TEST(tid.TPC == geo::TPCID::TPCID_t(15));
441 
442  // test comparison operators (exercise copy constructor too)
443  // - with TPC ID
444  BOOST_TEST_CHECKPOINT("Testing comparison with TPC ID");
445  geo::TPCID smaller_tid(cid, tid.TPC - 1), same_tid(tid),
446  larger_tid(cid, tid.TPC + 1);
447 
448  TestIDcomparison(tid, smaller_tid, same_tid, larger_tid);
449 
450 } // test_TPCID_nestedConstructor()
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_WireID_defaultConstructor ( )

Definition at line 638 of file geo_types_test.cc.

638  {
639 
640  BOOST_TEST_CHECKPOINT("Testing default-constructed wire ID");
641 
642  geo::WireID wid;
643 
644  // a default-constructed ID is invalid:
645  TestIDvalidity(wid, false);
646  TestSetIDvalidity(wid);
647 
648  BOOST_TEST(&wid.deepestIndex() == &wid.Wire);
649  BOOST_TEST(&makeConst(wid).deepestIndex() == &wid.Wire);
650 
651 } // test_WireID_defaultConstructor()
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
auto makeConst(T &var) -> decltype(auto)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (wire&#39;s).
Definition: geo_types.h:602
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
void test_WireID_directConstructor ( )

Definition at line 701 of file geo_types_test.cc.

701  {
702 
703  BOOST_TEST_CHECKPOINT("Testing wire ID constructed with indices");
704 
705  geo::WireID wid(1, 15, 32, 27);
706 
707  // an explicitly constructed ID is valid:
708  TestIDvalidity(wid, true);
709  TestSetIDvalidity(wid);
710 
711  // check the ID value
712  BOOST_TEST(wid.Cryostat == geo::CryostatID::CryostatID_t( 1));
713  BOOST_TEST(wid.TPC == geo::TPCID::TPCID_t(15));
714  BOOST_TEST(wid.Plane == geo::PlaneID::PlaneID_t(32));
715  BOOST_TEST(wid.Wire == geo::WireID::WireID_t(27));
716 
717  BOOST_TEST_CHECKPOINT("Testing comparison with same TPC ID");
718 
720  smaller_wid(1, 15, 32, 26), same_wid(1, 15, 32, 27),
721  larger_wid(1, 15, 32, 28);
722  TestIDcomparison(wid, smaller_wid, same_wid, larger_wid);
723 
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);
726  TestCompareSmallerID(wid, smaller_pid1);
727  TestCompareLargerID(wid, larger_pid1);
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);
730  TestCompareSmallerID(wid, smaller_pid2);
731  TestCompareLargerID(wid, larger_pid2);
732 
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);
735  TestCompareSmallerID(wid, smaller_tid1);
736  TestCompareLargerID(wid, larger_tid1);
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);
739  TestCompareSmallerID(wid, smaller_tid2);
740  TestCompareLargerID(wid, larger_tid2);
741 
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);
744  TestCompareSmallerID(wid, smaller_cid1);
745  TestCompareLargerID(wid, larger_cid1);
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);
748  TestCompareSmallerID(wid, smaller_cid2);
749  TestCompareLargerID(wid, larger_cid2);
750 
751  // make sure the ID with wire 0 is fine (it's not a bad ID!)
752  BOOST_TEST_CHECKPOINT("Testing wire ID constructed with a wire #0");
753 
754  // test setting and accessing a single index
755  BOOST_TEST(wid.getIndex<0U>() == 1);
756  wid.writeIndex<0U>() = 2;
757  BOOST_TEST(wid.getIndex<0U>() == 2);
758 
759  BOOST_TEST(wid.getIndex<1U>() == 15);
760  wid.writeIndex<1U>() = 19;
761  BOOST_TEST(wid.getIndex<1U>() == 19);
762 
763  BOOST_TEST(wid.getIndex<2U>() == 32);
764  wid.writeIndex<2U>() = 76;
765  BOOST_TEST(wid.getIndex<2U>() == 76);
766 
767  BOOST_TEST(wid.getIndex<3U>() == 27);
768  wid.writeIndex<3U>() = 45;
769  BOOST_TEST(wid.getIndex<3U>() == 45);
770 
771 
772  geo::WireID first_wid(0, 0, 0, 0);
773  TestIDvalidity(first_wid, true);
774  TestSetIDvalidity(first_wid);
775 
776  // - check the ID value
777  BOOST_TEST(first_wid.Cryostat == geo::CryostatID::CryostatID_t(0));
778  BOOST_TEST(first_wid.TPC == geo::TPCID::TPCID_t(0));
779  BOOST_TEST(first_wid.Plane == geo::PlaneID::PlaneID_t(0));
780  BOOST_TEST(first_wid.Wire == geo::WireID::WireID_t(0));
781 
782 } // test_WireID_directConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:561
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
void test_WireID_integralConstructor ( )

Definition at line 654 of file geo_types_test.cc.

654  {
655 
656  BOOST_TEST_CHECKPOINT("Testing integral-constructed wire ID");
657 
658 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
659  BOOST_TEST_MESSAGE(" (test skipped)");
660 #else
661  geo::WireID wid(1);
662 
663  BOOST_TEST_MESSAGE("WireID(1) = " << std::string(wid));
664 
665  geo::WireID::WireID_t what = wid;
666 
667  BOOST_TEST_MESSAGE("int(WireID(1)) = " << what);
668 
669 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
670 } // test_WireID_integralConstructor()
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:561
void test_WireID_nestedConstructor ( )

Definition at line 673 of file geo_types_test.cc.

673  {
674 
675  BOOST_TEST_CHECKPOINT("Testing ID-constructed wire ID");
676 
677  geo::PlaneID pid(1, 15, 32);
678  geo::WireID wid(pid, 27);
679 
680  // an explicitly constructed ID is valid:
681  TestIDvalidity(wid, true);
682  TestSetIDvalidity(wid);
683 
684  // check the ID value
685  BOOST_TEST(wid.Cryostat == geo::CryostatID::CryostatID_t( 1));
686  BOOST_TEST(wid.TPC == geo::TPCID::TPCID_t(15));
687  BOOST_TEST(wid.Plane == geo::PlaneID::PlaneID_t(32));
688  BOOST_TEST(wid.Wire == geo::WireID::WireID_t(27));
689 
690  // test comparison operators (exercise copy constructor too)
691  // - with TPC ID
692  BOOST_TEST_CHECKPOINT("Testing comparison with wire ID");
693  geo::WireID smaller_wid(pid, wid.Wire - 1), same_wid(wid),
694  larger_wid(pid, wid.Wire + 1);
695 
696  TestIDcomparison(wid, smaller_wid, same_wid, larger_wid);
697 
698 } // test_WireID_nestedConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
void TestIDvalidity(geo::CryostatID const &id, bool answer)
void TestSetIDvalidity(geo::CryostatID &id)
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:561
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
template<typename TESTID , typename REFID = TESTID>
void TestCompareLargerID ( TESTID const &  id,
REFID const &  larger 
)

Test comparison operators.

Definition at line 188 of file geo_types_test.cc.

188  {
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);
195 } // TestCompareLargerID()
template<typename TESTID , typename REFID = TESTID>
void TestCompareSameID ( TESTID const &  id,
REFID const &  same 
)

Test comparison operators.

Definition at line 172 of file geo_types_test.cc.

172  {
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);
179 } // TestCompareSameID()
template<typename TESTID >
void TestCompareSelfID ( TESTID const &  id)

Test comparison operators.

Definition at line 183 of file geo_types_test.cc.

184  { return TestCompareSameID(id, id); }
void TestCompareSameID(TESTID const &id, REFID const &same)
Test comparison operators.
template<typename TESTID , typename REFID = TESTID>
void TestCompareSmallerID ( TESTID const &  id,
REFID const &  smaller 
)

Test comparison operators.

Definition at line 161 of file geo_types_test.cc.

161  {
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);
168 } // TestCompareSmallerID()
template<typename TESTID , typename REFID = TESTID>
void TestIDcomparison ( TESTID const &  id,
REFID const &  smaller,
REFID const &  same,
REFID const &  larger 
)

Test comparison operators.

Definition at line 200 of file geo_types_test.cc.

205  {
206  TestCompareSmallerID(id, smaller);
207  TestCompareSameID(id, same);
208  TestCompareSelfID(id);
209  TestCompareLargerID(id, larger);
210 } // TestCryostatComparison()
void TestCompareSelfID(TESTID const &id)
Test comparison operators.
void TestCompareSameID(TESTID const &id, REFID const &same)
Test comparison operators.
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
void TestIDvalidity ( geo::CryostatID const &  id,
bool  answer 
)

Definition at line 133 of file geo_types_test.cc.

133  {
134  // - check isValid
135  BOOST_TEST(id.isValid == answer);
136  // - check operator!
137  BOOST_TEST(!id == !answer);
138  // - check operator bool
139  BOOST_TEST((bool)id == answer);
140 } // TestIDvalidity()
void TestSetIDvalidity ( geo::CryostatID id)

Definition at line 142 of file geo_types_test.cc.

142  {
143 
144  bool const orig = bool(id);
145 
146  id.setValidity(true);
147  BOOST_TEST(bool(id));
148  id.setValidity(false);
149  BOOST_TEST(!id);
150  id.markValid();
151  BOOST_TEST(bool(id));
152  id.markInvalid();
153  BOOST_TEST(!id);
154  id.setValidity(orig);
155  BOOST_TEST(bool(id) == orig);
156 
157 } // TestSetIDvalidity()
static constexpr bool