CbmRoot
_GTestCbmMuchDigi.cxx
Go to the documentation of this file.
1 #include "CbmMuchDigi.h"
2 
3 #include "gtest/gtest-spi.h"
4 #include "gtest/gtest.h"
5 
6 #include "compareMuchDigi.h"
7 
8 TEST(_GTestCbmMuchDigi, CheckDefaultConstructor) {
9  // Create object
10  CbmMuchDigi test;
11 
13 
14  CbmMuchDigi* test1 = new CbmMuchDigi();
15 
17 }
18 
19 
20 TEST(_GTestCbmMuchDigi, CheckStandardConstructor) {
21  // Create object
22  CbmMuchDigi test(111, 23, 987654321);
23 
24  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
25 
26  CbmMuchDigi* test1 = new CbmMuchDigi(111, 23, 987654321);
27 
28  compareMuchDigiDataMembers(*test1, 111, ECbmModuleId::kMuch, 987654321, 23);
29 }
30 
31 TEST(_GTestCbmMuchDigi, CheckCopyConstructor) {
32  // Create object
33  CbmMuchDigi test(111, 23, 987654321);
34 
35  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
36 
37  // Create object by copy constructing
38  // test should be equal to test2 and
39  // test should not be changed
40  CbmMuchDigi test2 {test};
41 
42 
43  compareMuchDigiDataMembers(test2, 111, ECbmModuleId::kMuch, 987654321, 23);
44 
45  // Test if the original object wasn't changed
46  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
47 }
48 
49 TEST(_GTestCbmMuchDigi, CheckAssignmentOperator) {
50 
51  // Create object
52  CbmMuchDigi test(111, 23, 987654321);
53 
54  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
55 
56  // Create object by copy assignment
57  // test should be equal to test2 and
58  // test should not be changed
59  CbmMuchDigi test2;
60  test2 = test;
61 
62  compareMuchDigiDataMembers(test2, 111, ECbmModuleId::kMuch, 987654321, 23);
63 
64  // Test if the original object wasn't changed
65  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
66 }
67 
68 TEST(_GTestCbmMuchDigi, CheckMoveConstructor) {
69  // Create object
70  CbmMuchDigi test(111, 23, 987654321);
71 
72  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
73 
74  // Create object by move constructing
75  CbmMuchDigi test2 {std::move(test)};
76 
77  compareMuchDigiDataMembers(test2, 111, ECbmModuleId::kMuch, 987654321, 23);
78 
79  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
80 }
81 
82 TEST(_GTestCbmMuchDigi, CheckAssignmentMoveConstructor) {
83  // Create object
84  CbmMuchDigi test(111, 23, 987654321);
85 
86  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
87 
88  // Create object by move constructing
89  CbmMuchDigi test2 {};
90  test2 = std::move(test);
91 
92  compareMuchDigiDataMembers(test2, 111, ECbmModuleId::kMuch, 987654321, 23);
93 
94  // For objects with simple types move fall back to copy so
95  // the original object is kept unchanged
96  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
97 }
98 
99 
100 TEST(_GTestCbmMuchDigi, CheckToString) {
101  // Create object
102  CbmMuchDigi test(111, 23, 987654321);
103 
104  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
105 
106  EXPECT_STREQ("", test.ToString().c_str());
107 }
108 
109 TEST(_GTestCbmMuchDigi, CheckGetClassName) {
110  // Create object
111  CbmMuchDigi test(111, 23, 987654321);
112 
113  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
114 
115  EXPECT_STREQ("CbmMuchDigi", test.GetClassName());
116 }
117 
118 TEST(_GTestCbmMuchDigi, CheckSetTime) {
119  // Create object
120  CbmMuchDigi test(111, 23, 987654321);
121 
122  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
123 
124  test.SetTime(12345678);
125 
126  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 12345678, 23);
127 }
128 
129 TEST(_GTestCbmMuchDigi, CheckSetAddress) {
130  // Create object
131  CbmMuchDigi test(111, 23, 987654321);
132 
133  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
134 
135  test.SetAddress(12341234);
136 
138  test, 12341234, ECbmModuleId::kMuch, 987654321, 23);
139 }
140 
141 TEST(_GTestCbmMuchDigi, CheckSetAdc) {
142  // Create object
143  CbmMuchDigi test(111, 23, 987654321);
144 
145  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
146 
147  test.SetAdc(12);
148 
149  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 12);
150 }
151 
152 TEST(_GTestCbmMuchDigi, CheckGetChannelId) {
153  // Create object
154  CbmMuchDigi test(111, 23, 987654321);
155 
156  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
157 
158  EXPECT_EQ(111, test.GetChannelId());
159 }
160 
161 TEST(_GTestCbmMuchDigi, CheckGetAdcCharge) {
162  // Create object
163  CbmMuchDigi test(111, 23, 987654321);
164 
165  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
166 
167  EXPECT_EQ(23, test.GetADCCharge());
168 }
169 
170 TEST(_GTestCbmMuchDigi, CheckGetDTime) {
171  // Create object
172  CbmMuchDigi test(111, 23, 987654321);
173 
174  compareMuchDigiDataMembers(test, 111, ECbmModuleId::kMuch, 987654321, 23);
175 
176  EXPECT_EQ(0, test.GetDTime());
177 }
178 
179 // TODO: Not tested yet is the setting of the saturation flag since there is
180 // no getter for this data member
181 // Is this data member needed at all if there is no accessor
182 // Also not tested is the function GetDetectorID since it needes knowledge
183 // of the internal address scheme
CbmMuchDigi.h
CbmMuchDigi::GetChannelId
Int_t GetChannelId() const
Definition: CbmMuchDigi.h:91
CbmMuchDigi::GetClassName
static const char * GetClassName()
Class name (static)
Definition: CbmMuchDigi.h:71
CbmMuchDigi::SetAddress
void SetAddress(Int_t address)
Definition: CbmMuchDigi.h:84
compareMuchDigi.h
compareMuchDigiDataMembers
void compareMuchDigiDataMembers(CbmMuchDigi &test, Int_t address, ECbmModuleId systemid, ULong64_t time, Int_t charge)
Definition: compareMuchDigi.h:4
CbmMuchDigi::ToString
std::string ToString() const
Definition: CbmMuchDigi.h:95
CbmMuchDigi::GetDTime
Int_t GetDTime() const
Definition: CbmMuchDigi.h:93
CbmMuchDigi
Definition: CbmMuchDigi.h:31
TEST
TEST(_GTestCbmMuchDigi, CheckDefaultConstructor)
Definition: _GTestCbmMuchDigi.cxx:8
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmMuchDigi::GetADCCharge
Int_t GetADCCharge() const
Definition: CbmMuchDigi.h:92
CbmMuchDigi::SetTime
void SetTime(ULong64_t time)
Definition: CbmMuchDigi.cxx:58
CbmMuchDigi::SetAdc
void SetAdc(Int_t adc)
Definition: CbmMuchDigi.cxx:34