All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_geoid_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_geoid_test.cxx
3  * @brief Unit test for geometry ID consistency on a standard detector
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date October 31, 2016
6  *
7  * Usage: just run the executable.
8  * Or plug a FHiCL file in the command line.
9  */
10 
11 // Boost test libraries; defining this symbol tells boost somehow to generate
12 // a main() function; Boost is pulled in by boost_unit_test_base.h
13 #define BOOST_TEST_MODULE GeometryGeoIDTest
14 
15 // LArSoft libraries
17 #include "GeometryGeoIDTestAlg.h"
21 
22 // utility libraries
23 
24 // C/C++ standard libraries
25 
26 //------------------------------------------------------------------------------
27 //--- The test environment
28 //---
29 
30 // we define here all the configuration that is needed;
31 // in the specific, the type of the channel mapping and a proper test name,
32 // used for output only; BasicGeometryEnvironmentConfiguration can read the
33 // configuration file name from command line, and
34 // BoostCommandLineConfiguration<> makes it initialize in time for Boost
35 // to catch it when instanciating the fixture.
38  testing::BasicGeometryEnvironmentConfiguration<geo::ChannelMapStandardAlg>
39  >
40 {
41  /// Constructor: overrides the application name
43  { SetApplicationName("GeometryGeoIDUnitTest"); }
44 }; // class StandardGeometryConfiguration
45 
46 /*
47  * Our fixture is based on GeometryTesterEnvironment, configured with the object
48  * above.
49  * It provides to the testing environment:
50  * - `Tester()`, returning a configured instance of the test algorithm;
51  * - `GlobalTester()`, (static) returning a global configured instance of the
52  * test algorithm.
53  *
54  * The testing::TestSharedGlobalResource<> facility provides a singleton
55  * instance of the tester algorithm, shared through the whole program and with
56  * this object too.
57  *
58  * This sharing allows the fixture to be used either as global or as per-suite.
59  * In the former case, the BOOST_AUTO_TEST_CASE's will access the global test
60  * algorithm instance through the static call to
61  * `GeometryGeoIDTestFixture::GlobalTester()`; in the latter case, it will
62  * access the local tester via the member function `Tester()`.
63  * In this case, whether `GlobalTester()` and `Tester()` point to the same
64  * tester depends on Boost unit test implementation.
65  */
67  private testing::GeometryTesterEnvironment<StandardGeometryConfiguration>
68 {
70 
72 
73  public:
74 
75  /// Constructor: initialize the tester with the Geometry from base class
77  {
78  // create a new tester
79  tester_ptr = std::make_shared<Tester_t>(TesterParameters());
80  tester_ptr->Setup(*(Provider<geo::GeometryCore>()));
81  // if no tester is default yet, share ours:
83  }
84 
85  /// Retrieves the local tester
86  Tester_t& Tester() { return *(tester_ptr.get()); }
87 
88  /// Retrieves the global tester
90 
91  private:
92  std::shared_ptr<Tester_t> tester_ptr; ///< our tester (may be shared)
93 }; // class GeometryGeoIDTestFixture
94 
95 
96 
97 //------------------------------------------------------------------------------
98 //--- The tests
99 //---
100 //
101 // BOOST_GLOBAL_FIXTURE does not provide tester access, so one has to get it
102 // as GeometryGeoIDTestFixture::GlobalTester(); on the other hand, the
103 // fixture is initialised only when a new global one is explicitly created.
104 //
105 
107 
108 BOOST_AUTO_TEST_CASE( CryostatGeoIDTest )
109 {
111 } // BOOST_AUTO_TEST_CASE( CryostatGeoIDTest )
112 
113 
114 
115 BOOST_AUTO_TEST_CASE( TPCGeoIDTest )
116 {
118 } // BOOST_AUTO_TEST_CASE( TPCGeoIDTest )
119 
120 
121 
122 BOOST_AUTO_TEST_CASE( PlaneGeoIDTest )
123 {
125 } // BOOST_AUTO_TEST_CASE( PlaneGeoIDTest )
126 
127 
128 
129 BOOST_AUTO_TEST_CASE( WireGeoIDTest )
130 {
132 } // BOOST_AUTO_TEST_CASE( WireGeoIDTest )
133 
134 
135 
136 // BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(AllTests)
Base class for objects initializing a geometry.
std::shared_ptr< Tester_t > tester_ptr
our tester (may be shared)
void SetApplicationName(std::string name)
Sets the name of the application.
BOOST_GLOBAL_FIXTURE(GeometryGeoIDTestFixture)
Access the description of detector geometry.
Class holding a configuration for a Boost test fixture.
StandardGeometryConfiguration()
Constructor: overrides the application name.
static Resource_t & Resource(std::string name="")
Retrieves the specified resource, or throws if not available.
Tests the correct assignment of IDs to detector geometry objects.
Environment for a geometry test.
Utility class providing singleton objects to the derived classes.
Tester_t & Tester()
Retrieves the local tester.
Base class for tests using Boost unit test library.
fhicl::ParameterSet TesterParameters() const
Returns the configuration of the main test (undefined if no main test)
static ResourcePtr_t ProvideDefaultSharedResource(ResourcePtr_t res_ptr)
Creates a shared resource as default only if none exists yet.
Interface to algorithm class for a specific detector channel mapping.
GeometryGeoIDTestFixture()
Constructor: initialize the tester with the Geometry from base class.
static Tester_t & GlobalTester()
Retrieves the global tester.