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
16 #include "test/Geometry/geometry_unit_test_base.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("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:
82  TesterRegistry_t::ProvideDefaultSharedResource(tester_ptr);
83  }
84 
85  /// Retrieves the local tester
86  Tester_t& Tester() { return *(tester_ptr.get()); }
87 
88  /// Retrieves the global tester
89  static Tester_t& GlobalTester() { return TesterRegistry_t::Resource(); }
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(CryostatIDIteratorsTest)
GeometryIteratorTestFixture()
Constructor: initialize the tester with the Geometry from base class.
BOOST_GLOBAL_FIXTURE(GeometryIteratorTestFixture)
Tests the correct iteration of the geo::Geometry iterators.
Tester_t & Tester()
Retrieves the local tester.
Class holding a configuration for a Boost test fixture.
StandardGeometryConfiguration()
Constructor: overrides the application name.
testing::TestSharedGlobalResource< Tester_t > TesterRegistry_t
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)
Access the description of detector geometry.
static Tester_t & GlobalTester()
Retrieves the global tester.
void SetApplicationName(string const &applicationName)