geometry_crmchannelmapping_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_crmchannelmapping_test.cxx
3  * @brief Unit test of channel mapping on a CRM-mapping detector
4  * @date October 13th, 2016
5  * @author Gianluca Petrillo (petrillo@fnal.gov)
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 GeometryCRMChannelMappingTest
14 
15 // LArSoft libraries
17 #include "test/Geometry/geometry_unit_test_base.h"
21 
22 // utility libraries
24 
25 // C/C++ standard libraries
26 #include <string>
27 
28 //------------------------------------------------------------------------------
29 //--- The test environment
30 //---
31 
32 // we define here all the configuration that is needed;
33 // in the specific, the type of the channel mapping and a proper test name,
34 // used for output only; BasicGeometryEnvironmentConfiguration can read the
35 // configuration file name from command line, and
36 // BoostCommandLineConfiguration<> makes it initialise in time for Boost
37 // to catch it when instantiating the fixture.
40  testing::BasicGeometryEnvironmentConfiguration<geo::ChannelMapCRMAlg>
41  >
42 {
43  /// Constructor: overrides the application name
45  { SetApplicationName("GeometryCRMChannelMappingTest"); }
46 }; // class CRMGeometryConfiguration
47 
48 /*
49  * Our fixture is based on GeometryTesterEnvironment, configured with the object
50  * above.
51  * It provides to the testing environment:
52  * - `Tester()`, returning a configured instance of the test algorithm;
53  * - `GlobalTester()`, (static) returning a global configured instance of the
54  * test algorithm.
55  *
56  * The testing::TestSharedGlobalResource<> facility provides a singleton
57  * instance of the tester algorithm, shared through the whole program and with
58  * this object too.
59  *
60  * This sharing allows the fixture to be used either as global or as per-suite.
61  * In the former case, the BOOST_AUTO_TEST_CASE's will access the global test
62  * algotithm instance through the static call to
63  * `GeometryCRMChannelMappingTestFixture::GlobalTester()`; in the latter
64  * case, it will access the local tester via the member function `Tester()`.
65  * In this case, whether `GlobalTester()` and `Tester()` point to the same
66  * tester depends on Boost unit test implementation.
67  */
69  private testing::GeometryTesterEnvironment<CRMGeometryConfiguration>
70 {
72 
74 
75  public:
76 
77  /// Constructor: initialize the tester with the Geometry from base class
79  {
80  // create a new tester
81  tester_ptr = std::make_shared<Tester_t>(TesterParameters());
82  tester_ptr->Setup(*(Provider<geo::GeometryCore>()));
83  // if no tester is default yet, share ours:
84  TesterRegistry_t::ProvideDefaultSharedResource(tester_ptr);
85  }
86 
87  /// Retrieves the local tester
88  Tester_t& Tester() { return *(tester_ptr.get()); }
89 
90  /// Retrieves the global tester
91  static Tester_t& GlobalTester() { return TesterRegistry_t::Resource(); }
92 
93  private:
94  std::shared_ptr<Tester_t> tester_ptr; ///< our tester (may be shared)
95 }; // class GeometryCRMChannelMappingTestFixture
96 
97 
98 
99 //------------------------------------------------------------------------------
100 //--- The tests
101 //---
102 //
103 // Note on Boost fixture options:
104 // - BOOST_FIXTURE_TEST_SUITE will provide the tester as a always-present data
105 // member in the environment, as "Tester()"; but a new fixture, with a new
106 // geometry and a new tester, is initialised on each test case
107 // - BOOST_GLOBAL_FIXTURE does not provide tester access, so one has to get it
108 // as GeometryCRMChannelMappingTestFixture::GlobalTester(); on the other
109 // hand, the fixture is initialised only when a new global one is explicitly
110 // created.
111 //
112 
114 
115 BOOST_AUTO_TEST_CASE( TPCsetMappingTestCase )
116 {
118 } // BOOST_AUTO_TEST_CASE( TPCsetMappingTestCase )
119 
120 BOOST_AUTO_TEST_CASE( ROPMappingTestCase )
121 {
123 } // BOOST_AUTO_TEST_CASE( ROPMappingTestCase )
124 
125 BOOST_AUTO_TEST_CASE( ChannelMappingTestCase )
126 {
129 } // BOOST_AUTO_TEST_CASE( ChannelMappingTestCase )
130 
void ChannelMappingTest() const
Tests channel mappings (very, very partial)
testing::TestSharedGlobalResource< Tester_t > TesterRegistry_t
void ROPMappingTest() const
Tests ROP mappings.
std::shared_ptr< Tester_t > tester_ptr
our tester (may be shared)
Class holding a configuration for a Boost test fixture.
Environment for a geometry test.
CRMGeometryConfiguration()
Constructor: overrides the application name.
Interface to algorithm class for a dual-phase detector channel mapping.
Utility class providing singleton objects to the derived classes.
static Tester_t & GlobalTester()
Retrieves the global tester.
Tests the standard channel mapping algorithm.
GeometryCRMChannelMappingTestFixture()
Constructor: initialize the tester with the Geometry from base class.
Tester_t & Tester()
Retrieves the local tester.
BOOST_GLOBAL_FIXTURE(GeometryCRMChannelMappingTestFixture)
void TPCsetMappingTest() const
Tests TPCset mappings.
Access the description of detector geometry.
BOOST_AUTO_TEST_CASE(TPCsetMappingTestCase)
void SetApplicationName(string const &applicationName)