All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_standardchannelmapping_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_standardchannelmapping_test.cxx
3  * @brief Unit test of channel mapping on a standard detector
4  * @date June 26th, 2015
5  * @author 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 GeometryStandardChannelMappingTest
14 
15 // LArSoft libraries
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("GeometryStandardChannelMappingTest"); }
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  * algotithm instance through the static call to
61  * `GeometryStandardChannelMappingTestFixture::GlobalTester()`; in the latter
62  * case, it will 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 GeometryStandardChannelMappingTestFixture
94 
95 
96 
97 //------------------------------------------------------------------------------
98 //--- The tests
99 //---
100 //
101 // Note on Boost fixture options:
102 // - BOOST_FIXTURE_TEST_SUITE will provide the tester as a always-present data
103 // member in the environment, as "Tester()"; but a new fixture, with a new
104 // geometry and a new tester, is initialized on each test case
105 // - BOOST_GLOBAL_FIXTURE does not provide tester access, so one has to get it
106 // as GeometryStandardChannelMappingTestFixture::GlobalTester(); on the other
107 // hand, the fixture is initialized only when a new global one is explicitly
108 // created.
109 //
110 
112 
113 BOOST_AUTO_TEST_CASE( TPCsetMappingTestCase )
114 {
116 } // BOOST_AUTO_TEST_CASE( TPCsetMappingTestCase )
117 
118 BOOST_AUTO_TEST_CASE( ROPMappingTestCase )
119 {
121 } // BOOST_AUTO_TEST_CASE( ROPMappingTestCase )
122 
123 BOOST_AUTO_TEST_CASE( ChannelMappingTestCase )
124 {
127 } // BOOST_AUTO_TEST_CASE( ChannelMappingTestCase )
128 
129 
130 // BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(AllTests)
Base class for objects initializing a geometry.
GeometryStandardChannelMappingTestFixture()
Constructor: initialize the tester with the Geometry from base class.
void ChannelMappingTest() const
Tests channel mappings (very, very partial)
void SetApplicationName(std::string name)
Sets the name of the application.
void ROPMappingTest() const
Tests ROP mappings.
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.
Environment for a geometry test.
static Tester_t & GlobalTester()
Retrieves the global tester.
Utility class providing singleton objects to the derived classes.
std::shared_ptr< Tester_t > tester_ptr
our tester (may be shared)
Base class for tests using Boost unit test library.
Tests the standard channel mapping algorithm.
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.
void TPCsetMappingTest() const
Tests TPCset mappings.