CbmRoot
_GTestCbmPsdDigi.cxx
Go to the documentation of this file.
1 #include "CbmPsdDigi.h"
2 
3 #include "gtest/gtest-spi.h"
4 #include "gtest/gtest.h"
5 
6 #include "comparePsdDigi.h"
7 
8 TEST(_GTestCbmPsdDigi, CheckDefaultConstructor) {
9  // Create object
10  CbmPsdDigi test;
11 
13 
14  CbmPsdDigi* test1 = new CbmPsdDigi();
15 
16  comparePsdDigiDataMembers(*test1, 0, ECbmModuleId::kPsd, -1., 0.);
17 }
18 
19 TEST(_GTestCbmPsdDigi, CheckStandardConstructor) {
20  // Create object
21  CbmPsdDigi test(111, 987654321., 23.);
22 
23  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
24 
25  CbmPsdDigi* test1 = new CbmPsdDigi(111, 987654321., 23.);
26 
27  comparePsdDigiDataMembers(*test1, 111, ECbmModuleId::kPsd, 23., 987654321.);
28 }
29 
30 TEST(_GTestCbmPsdDigi, CheckConstructorWithDetailedAssignment) {
31  // Create object
32  CbmPsdDigi test(1, 5, 987654321., 23.);
33 
34  comparePsdDigiDataMembers(test, 5144, ECbmModuleId::kPsd, 23., 987654321.);
35 
36  CbmPsdDigi* test1 = new CbmPsdDigi(5, 5, 987654321., 23.);
37 
38  comparePsdDigiDataMembers(*test1, 5208, ECbmModuleId::kPsd, 23., 987654321.);
39 }
40 
41 TEST(_GTestCbmPsdDigi, CheckCopyConstructor) {
42  // Create object
43  CbmPsdDigi test(111, 987654321., 23.);
44 
45  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
46 
47  // Create object by copy constructing
48  // test should be equal to test2 and
49  // test should not be changed
50  CbmPsdDigi test2 {test};
51 
52  comparePsdDigiDataMembers(test2, 111, ECbmModuleId::kPsd, 23., 987654321.);
53 
54  // Test if the original object wasn't changed
55  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
56 }
57 
58 TEST(_GTestCbmPsdDigi, CheckAssignmentOperator) {
59 
60  // Create object
61  CbmPsdDigi test(111, 987654321., 23.);
62 
63  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
64 
65  // Create object by copy assignment
66  // test should be equal to test2 and
67  // test should not be changed
68  CbmPsdDigi test2;
69  test2 = test;
70 
71  comparePsdDigiDataMembers(test2, 111, ECbmModuleId::kPsd, 23., 987654321.);
72 
73  // Test if the original object wasn't changed
74  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
75 }
76 
77 TEST(_GTestCbmPsdDigi, CheckMoveConstructor) {
78  // Create object
79  CbmPsdDigi test(111, 987654321., 23.);
80 
81  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
82 
83  // Create object by move constructing
84  CbmPsdDigi test2 {std::move(test)};
85 
86  comparePsdDigiDataMembers(test2, 111, ECbmModuleId::kPsd, 23., 987654321.);
87 
88  // For objects with simple types move fall back to copy so
89  // the original object is kept unchanged
90  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
91 }
92 
93 TEST(_GTestCbmPsdDigi, CheckAssignmentMoveConstructor) {
94  // Create object
95  CbmPsdDigi test(111, 987654321., 23.);
96 
97  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
98 
99  // Create object by move constructing
100  CbmPsdDigi test2 {}; // = std::move(test);
101  test2 = std::move(test);
102 
103  comparePsdDigiDataMembers(test2, 111, ECbmModuleId::kPsd, 23., 987654321.);
104 
105 
106  // For objects with simple types move fall back to copy so
107  // the original object is kept unchanged
108  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
109 }
110 
111 
112 TEST(_GTestCbmPsdDigi, CheckToString) {
113  // Create object
114  CbmPsdDigi test(12341234, 987654321., 23.);
115 
117  test, 12341234, ECbmModuleId::kPsd, 23., 987654321.);
118 
119  EXPECT_STREQ("CbmPsdDigi: address = 0x00BC4FF2 Charge = 987654321.000000 "
120  "Time = 23.000000",
121  test.ToString().c_str());
122 }
123 
124 TEST(_GTestCbmPsdDigi, CheckGetClassName) {
125  // Create object
126  CbmPsdDigi test(111, 987654321., 23.);
127 
128  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
129 
130  EXPECT_STREQ("CbmPsdDigi", test.GetClassName());
131 }
132 
133 TEST(_GTestCbmPsdDigi, CheckSetTime) {
134  // Create object
135  CbmPsdDigi test(111, 987654321., 23.);
136 
137  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
138 
139  test.SetTime(12345678.);
140 
142  test, 111, ECbmModuleId::kPsd, 12345678., 987654321.);
143 }
144 
145 TEST(_GTestCbmPsdDigi, CheckSetAddress) {
146  // Create object
147  CbmPsdDigi test(111, 987654321., 23.);
148 
149  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
150 
151  test.SetAddress(12341234);
152 
154  test, 12341234, ECbmModuleId::kPsd, 23., 987654321.);
155 }
156 
157 TEST(_GTestCbmPsdDigi, CheckSetAddressWithModuleAndSection) {
158  // Create object
159  CbmPsdDigi test(111, 987654321., 23.);
160 
161  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
162 
163  test.SetAddress(1, 5);
164 
165  comparePsdDigiDataMembers(test, 5144, ECbmModuleId::kPsd, 23., 987654321.);
166 }
167 
168 TEST(_GTestCbmPsdDigi, CheckSetEdep) {
169  // Create object
170  CbmPsdDigi test(111, 987654321., 23.);
171 
172  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 987654321.);
173 
174  test.SetEdep(45.);
175 
176  comparePsdDigiDataMembers(test, 111, ECbmModuleId::kPsd, 23., 45.);
177 }
CbmPsdDigi.h
CbmPsdDigi::ToString
std::string ToString() const
String output.
Definition: CbmPsdDigi.cxx:78
CbmPsdDigi::SetTime
void SetTime(Double_t time)
Definition: CbmPsdDigi.h:134
comparePsdDigi.h
TEST
TEST(_GTestCbmPsdDigi, CheckDefaultConstructor)
Definition: _GTestCbmPsdDigi.cxx:8
comparePsdDigiDataMembers
void comparePsdDigiDataMembers(CbmPsdDigi &test, Int_t address, ECbmModuleId systemid, Double_t time, Double_t edep)
Definition: comparePsdDigi.h:4
CbmPsdDigi::SetEdep
void SetEdep(Double_t edep)
Definition: CbmPsdDigi.h:133
CbmPsdDigi::GetClassName
static const char * GetClassName()
Class name (static)
Definition: CbmPsdDigi.h:93
ECbmModuleId::kPsd
@ kPsd
Projectile spectator detector.
CbmPsdDigi
Data class for PSD digital information.
Definition: CbmPsdDigi.h:31
CbmPsdDigi::SetAddress
void SetAddress(Int_t address)
Definition: CbmPsdDigi.h:131