BoostedAtomicNumber_test.cc
Go to the documentation of this file.
1 /**
2  * @file BoostedAtomicNumber_test.cc
3  * @brief Tests the AtomicNumber service provider (with Boost unit test)
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 14, 2016
6  * @see AtomicNumber.h
7  * @ingroup AtomicNumber
8  *
9  *
10  * This test takes a configuration file as first command line argument.
11  * The content of the configuration file is expected to include:
12  * - a `services.AtomicNumberService` section with the configuration of the
13  * provider
14  * - a `physics.analyzers.expected` section with the expected values (same
15  * format as the service configuration)
16  *
17  */
18 
19 
20 // LArSoft libraries
21 #define BOOST_TEST_MODULE (Boosted atomic number test)
23 #include "larcorealg/TestUtils/unit_test_base.h" // testing::TesterEnvironment
24 #include "larcorealg/TestUtils/boost_unit_test_base.h" // testing::BoostCommandLineConfiguration
25 
26 // BEGIN AtomicNumber ----------------------------------------------------------
27 /// @ingroup AtomicNumber
28 /// @{
29 
30 //------------------------------------------------------------------------------
31 //--- Testing environment
32 //---
36  >;
37 
39 
40  // Constructor (to give a name to the test)
42  : BoostBasicFixture( "BoostedAtomicNumber_test" )
43  , Zprov(ServiceParameters("AtomicNumberService"))
44  , pset_expected(TesterParameters("expected"))
45  {}
46 
47  // public provider
49 
50  // expected values (as a parameter set)
52 
53 }; // AtomicNumberTestFixture
54 
55 
56 //------------------------------------------------------------------------------
57 BOOST_FIXTURE_TEST_SUITE(BoostedAtomicNumberTest, AtomicNumberTestFixture)
58 
60 
61  // these are the results we expect:
62  auto const expected_Z = pset_expected.get<unsigned int>("AtomicNumber");
63 
64  // here goes the test... Zprov is the data member of the fixture
65  BOOST_TEST(Zprov.Z() == expected_Z);
66 
67 } // BOOST_AUTO_TEST_CASE(AllTests)
68 
69 BOOST_AUTO_TEST_SUITE_END()
70 
71 /// @}
72 // END AtomicNumber ------------------------------------------------------------
Class holding a configuration for a test environment.
Provider returning atomic number of the active material in the TPC.
Class holding a configuration for a Boost test fixture.
unsigned int Z() const
Returns the atomic number.
Definition: AtomicNumber.h:84
testing::TesterEnvironment< testing::BoostCommandLineConfiguration< testing::BasicEnvironmentConfiguration > > BoostBasicFixture
T get(std::string const &key) const
Definition: ParameterSet.h:271
Provides information about the active material in the TPC.
Definition: AtomicNumber.h:38
A test environment with some support for service providers.
fhicl::ParameterSet const pset_expected
lar::example::AtomicNumber const Zprov
BOOST_AUTO_TEST_CASE(AllTests)