All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar::ServicePackTest Class Reference

Test module for ServicePack.h utilities depending on art farmework. More...

Inheritance diagram for lar::ServicePackTest:

Public Member Functions

 ServicePackTest (fhicl::ParameterSet const &)
 

Private Member Functions

void beginJob () override
 Run event-independent tests. More...
 
void analyze (const art::Event &) override
 Run event-dependent tests (none so far) More...
 
void endJob () override
 Throws if errors have been accumulated. More...
 
Test functions
void extractProviders_test_plain ()
 Tests lar::extractProviders() More...
 
void extractProviders_test_permuted ()
 Tests lar::extractProviders() and permuted constructor. More...
 
void extractProviders_test_reduced ()
 Tests lar::extractProviders() and assignment to reduced pack. More...
 
void extractProviders_tests ()
 All tests on lar::extractProviders() More...
 

Private Attributes

std::vector< std::string > errors
 list of collected errors More...
 

Detailed Description

Test module for ServicePack.h utilities depending on art farmework.

Currently exercises:

Throws an exception on failure.

Service requirements

This module requires the following services to be configured:

Configuration parameters

Currently none.

Definition at line 75 of file ServicePackTest_module.cc.

Constructor & Destructor Documentation

lar::ServicePackTest::ServicePackTest ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 122 of file ServicePackTest_module.cc.

122 : EDAnalyzer(pset) {}

Member Function Documentation

void lar::ServicePackTest::analyze ( const art::Event &  )
inlineoverrideprivate

Run event-dependent tests (none so far)

Definition at line 85 of file ServicePackTest_module.cc.

86  {}
void lar::ServicePackTest::beginJob ( )
overrideprivate

Run event-independent tests.

Definition at line 126 of file ServicePackTest_module.cc.

127  {
129  } // ServicePackTest::beginJob()
void extractProviders_tests()
All tests on lar::extractProviders()
void lar::ServicePackTest::endJob ( )
overrideprivate

Throws if errors have been accumulated.

Definition at line 133 of file ServicePackTest_module.cc.

134  {
135  if (errors.empty()) {
136  mf::LogInfo("ServicePackTest") << "All tests were successful.";
137  return;
138  }
139 
140  mf::LogError log("ServicePackTest");
141  log << errors.size() << " errors detected:";
142 
143  for (std::string const& error : errors)
144  log << "\n - " << error;
145 
146  throw art::Exception(art::errors::LogicError) << errors.size() << " errors detected";
147  }
std::vector< std::string > errors
list of collected errors
void lar::ServicePackTest::extractProviders_test_permuted ( )
private

Tests lar::extractProviders() and permuted constructor.

Definition at line 191 of file ServicePackTest_module.cc.

192  {
193  /*
194  * The test creates a ProviderPack and checks that its element as as
195  * expected.
196  *
197  * The expected value is extracted from the framework in the "traditional"
198  * way.
199  *
200  * The order of the providers is different from the order of the services;
201  * in this way a "wrong" ProviderPack will be (deliberately) created,
202  * and the code will have to convert it to the right pack.
203  */
204 
205  // these are the "solutions":
206  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
207  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
208 
209  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
210 
211  // check time
212  if (providers.get<geo::GeometryCore>() != geom) {
213  errors.push_back("wrong geometry provider (got " +
214  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
215  ::to_string(geom) + ") [permuted]");
216  }
217  if (providers.get<detinfo::LArProperties>() != larprop) {
218  errors.push_back("wrong LAr properties provider (got " +
219  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
220  ::to_string(larprop) + ") [permuted]");
221  }
222  }
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(WindowPattern const &pattern)
void lar::ServicePackTest::extractProviders_test_plain ( )
private

Tests lar::extractProviders()

Definition at line 160 of file ServicePackTest_module.cc.

161  {
162  /*
163  * The test creates a ProviderPack and checks that its element as as
164  * expected.
165  *
166  * The expected value is extracted from the framework in the "traditional"
167  * way.
168  */
169 
170  // these are the "solutions":
171  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
172  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
173 
174  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
175 
176  // check time
177  if (providers.get<geo::GeometryCore>() != geom) {
178  errors.push_back("wrong geometry provider (got " +
179  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
180  ::to_string(geom) + ")");
181  }
182  if (providers.get<detinfo::LArProperties>() != larprop) {
183  errors.push_back("wrong LAr properties provider (got " +
184  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
185  ::to_string(larprop) + ")");
186  }
187  } // ServicePackTest::extractProviders_test_plain()
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(WindowPattern const &pattern)
void lar::ServicePackTest::extractProviders_test_reduced ( )
private

Tests lar::extractProviders() and assignment to reduced pack.

Definition at line 226 of file ServicePackTest_module.cc.

227  {
228  /*
229  * The test creates a ProviderPack and checks that its element as as
230  * expected.
231  *
232  * The expected value is extracted from the framework in the "traditional"
233  * way.
234  *
235  * We use a smaller provider pack to store the providers;
236  * DetectorProperties will be dropped.
237  */
238 
239  // these are the "solutions":
240  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
241  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
242  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
243 
244  // check time
245  if (providers.get<geo::GeometryCore>() != geom) {
246  errors.push_back("wrong geometry provider (got " +
247  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
248  ::to_string(geom) + ") [reduced]");
249  }
250  if (providers.get<detinfo::LArProperties>() != larprop) {
251  errors.push_back("wrong LAr properties provider (got " +
252  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
253  ::to_string(larprop) + ") [reduced]");
254  }
255  }
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(WindowPattern const &pattern)
void lar::ServicePackTest::extractProviders_tests ( )
private

All tests on lar::extractProviders()

Definition at line 151 of file ServicePackTest_module.cc.

152  {
156  }
void extractProviders_test_reduced()
Tests lar::extractProviders() and assignment to reduced pack.
void extractProviders_test_plain()
Tests lar::extractProviders()
void extractProviders_test_permuted()
Tests lar::extractProviders() and permuted constructor.

Member Data Documentation

std::vector<std::string> lar::ServicePackTest::errors
private

list of collected errors

Definition at line 108 of file ServicePackTest_module.cc.


The documentation for this class was generated from the following file: