PointCharge_test.cc
Go to the documentation of this file.
1 /**
2  * @file PointCharge_test.cc
3  * @brief Simple test on a recob::PointCharge object.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date December 20, 2017
6  * @version 1.0
7  *
8  * This test simply creates recob::PointCharge objects and verifies that the
9  * values it can access are the right ones.
10  *
11  * See http://www.boost.org/libs/test for the Boost test library home page.
12  */
13 
14 // C/C++ standard library
15 
16 // Boost libraries
17 #define BOOST_TEST_MODULE ( charge_test )
18 #include "boost/test/unit_test.hpp"
19 
20 
21 // LArSoft libraries
23 
24 
25 
26 //------------------------------------------------------------------------------
27 //--- Test code
28 //
29 
30 
32  recob::PointCharge const& obj,
33  bool hasCharge,
35 ) {
36 
37  // verify that the values are as expected
38  if (hasCharge) {
39  BOOST_TEST(obj.hasCharge());
40  BOOST_TEST(obj.charge() == charge);
41  }
42  else {
43  BOOST_TEST(!obj.hasCharge());
44  // charge() return value is undefined
45  }
46 
47 } // CheckCharge()
48 
49 
51 
52  //
53  // Part I: initialization of inputs
54  //
55  // these are the values expected for a default-constructed wire
56  bool const hasCharge = false;
58 
59  //
60  // Part II: default constructor
61  //
62  // step II.1: create a charge with the default constructor
63  recob::PointCharge chargeInfo;
64 
65  // step II.2: verify that the values are as expected
66  CheckCharge(chargeInfo, hasCharge, charge);
67 
68 } // ChargeTestDefaultConstructor()
69 
70 
72  //
73  // Part I: initialization of inputs
74  //
75  // these are the values expected for a value-constructed wire
76  bool const hasCharge = true;
77  recob::PointCharge::Charge_t const charge = 10.0;
78 
79  //
80  // Part II: default constructor
81  //
82  // step II.1: create a charge with the value constructor
83  recob::PointCharge chargeInfo(charge);
84 
85  // step II.2: verify that the values are as expected
86  CheckCharge(chargeInfo, hasCharge, charge);
87 
88 } // ChargeTestValueConstructors()
89 
90 
91 //------------------------------------------------------------------------------
92 //--- registration of tests
93 //
94 
95 BOOST_AUTO_TEST_CASE(ChargeTestDefaultConstructor_testcase) {
97 } // ChargeTestDefaultConstructor_testcase
98 
99 BOOST_AUTO_TEST_CASE(ChargeTestValueConstructor_testcase) {
101 } // ChargeTestValueConstructor_testcase
102 
BOOST_AUTO_TEST_CASE(ChargeTestDefaultConstructor_testcase)
void ChargeTestDefaultConstructor()
void CheckCharge(recob::PointCharge const &obj, bool hasCharge, recob::PointCharge::Charge_t charge)
static constexpr Charge_t InvalidCharge
Value used for default-constructed ("invalid") charge.
Definition: PointCharge.h:39
Information about charge reconstructed in the active volume.
constexpr bool hasCharge() const
Returns whether the reconstructed charge value is valid.
Definition: PointCharge.h:76
float Charge_t
Type for the amount of reconstructed charge.
Definition: PointCharge.h:35
void ChargeTestValueConstructors()
constexpr Charge_t charge() const
Returns the stored value of the reconstructed charge.
Definition: PointCharge.h:65
Charge reconstructed in the active volume.
Definition: PointCharge.h:31