All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geometry_iterator_test.cxx
Go to the documentation of this file.
1 /**
2  * @file geometry_iterator_test.cxx
3  * @brief Unit test for geometry iterators on a standard detector
4  * @date May 7th, 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 GeometryIteratorTest
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("GeometryIteratorUnitTest"); }
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  * `GeometryIteratorTestFixture::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 GeometryIteratorTestFixture
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 GeometryIteratorTestFixture::GlobalTester(); on the other hand, the
107 // fixture is initialized only when a new global one is explicitly created.
108 //
109 
110 // BOOST_FIXTURE_TEST_SUITE(GeometryIterators, GeometryIteratorTestFixture)
112 
113 /*
114 BOOST_AUTO_TEST_CASE( AllTests )
115 {
116  GlobalTester().Run();
117 } // BOOST_AUTO_TEST_CASE( AllTests )
118 */
119 
120 BOOST_AUTO_TEST_CASE( CryostatIDIteratorsTest )
121 {
123 } // BOOST_AUTO_TEST_CASE( CryostatIDIteratorsTest )
124 
125 
126 
127 BOOST_AUTO_TEST_CASE( CryostatIteratorsTest )
128 {
130 } // BOOST_AUTO_TEST_CASE( CryostatIteratorsTest )
131 
132 
133 
134 BOOST_AUTO_TEST_CASE( TPCIDIteratorsTest )
135 {
137 } // BOOST_AUTO_TEST_CASE( TPCIDIteratorsTest )
138 
139 
140 
141 BOOST_AUTO_TEST_CASE( TPCIteratorsTest )
142 {
144 } // BOOST_AUTO_TEST_CASE( TPCIteratorsTest )
145 
146 
147 
148 BOOST_AUTO_TEST_CASE( PlaneIDIteratorsTest )
149 {
151 } // BOOST_AUTO_TEST_CASE( PlaneIDIteratorsTest )
152 
153 
154 
155 BOOST_AUTO_TEST_CASE( PlaneIteratorsTest )
156 {
158 } // BOOST_AUTO_TEST_CASE( PlaneIteratorsTest )
159 
160 
161 
162 BOOST_AUTO_TEST_CASE( WireIDIteratorsTest )
163 {
165 } // BOOST_AUTO_TEST_CASE( WireIDIteratorsTest )
166 
167 
168 
169 BOOST_AUTO_TEST_CASE( WireIteratorsTest )
170 {
172 } // BOOST_AUTO_TEST_CASE( WireIteratorsTest )
173 
174 
175 // BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(AllTests)
Base class for objects initializing a geometry.
void SetApplicationName(std::string name)
Sets the name of the application.
GeometryIteratorTestFixture()
Constructor: initialize the tester with the Geometry from base class.
Tests the correct iteration of the geo::Geometry iterators.
Tester_t & Tester()
Retrieves the local tester.
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.
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.
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.
static Tester_t & GlobalTester()
Retrieves the global tester.