All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ValidateAtomicNumberConfiguration_test.cc
Go to the documentation of this file.
1 /**
2  * @file ValidateAtomicNumberConfiguration_test.cc
3  * @brief Validates the AtomicNumber service provider configuration
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 18, 2016
6  * @see AtomicNumber.h
7  * @ingroup AtomicNumber
8  *
9  * This test expects a single configuration file to be specified as first
10  * argument.
11  *
12  */
13 
14 
15 // LArSoft libraries
17 #include "larcorealg/TestUtils/unit_test_base.h" // testing namespace
18 
19 // support libraries
20 #include "fhiclcpp/types/Name.h"
21 
22 // C/C++ standard libraries
23 #include <iostream> // std::cout
24 #include <string>
25 #include <stdexcept> // std::runtime_error
26 
27 
28 // BEGIN AtomicNumber ----------------------------------------------------------
29 /// @ingroup AtomicNumber
30 /// @{
31 
32 //------------------------------------------------------------------------------
33 int main(int argc, char** argv) {
34 
35  //
36  // configuration of the test
37  //
38 
39  // provide a test name;
40  // the path to the configuration file will be taken from the first parameter
42  (argc, argv, "ValidateAtomicNumberConfiguration_test");
43 
44  // set up a basic testing environment with that configuration
45  auto TesterEnv = testing::CreateTesterEnvironment(config);
46 
47  // create a configuration table; here the name is irrelevant
49  (fhicl::Name("AtomicNumberService"));
50 
51  // print the configuration
52  mf::LogVerbatim("ValidateAtomicNumberConfiguration") << std::string(80, '-')
53  << "\nAllowed configuration for AtomicNumber provider:";
54  providerConfig.print_allowed_configuration(std::cout);
55 
56  //
57  // test of the configuration
58  //
59 
60  mf::LogVerbatim("ValidateAtomicNumberConfiguration") << std::string(80, '-')
61  << "\nValidating configuration from '"
62  << config.ServiceParameterSetPath("AtomicNumberService")
63  << "' in '" << config.ConfigurationPath() << "':";
64  // this will trigger validation
65  // and throw fhicl::detail::validationException on error
66  providerConfig.validate_ParameterSet
67  (TesterEnv.ServiceParameters("AtomicNumberService"), { "service_type" });
68 
69  //
70  // done!
71  //
72  return 0;
73 } // main()
74 
75 /// @}
76 // END AtomicNumber ------------------------------------------------------------
Class holding a configuration for a test environment.
fhicl::Table< Config > parameters_type
Type describing all the parameters.
Definition: AtomicNumber.h:58
Provider returning atomic number of the active material in the TPC.
std::string ServiceParameterSetPath(std::string name) const
FHiCL path for the configuration of the service.
TESTENV CreateTesterEnvironment(CONFIG &&config, ARGS...other_args)
Constructs and returns a TesterEnvironment object.
BEGIN_PROLOG vertical distance to the surface Name
std::string ConfigurationPath() const
Path to the configuration file.
int main(int argc, char **argv)
Base class for unit tests using FHiCL configuration.
BEGIN_PROLOG could also be cout