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