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