CbmRoot
Loading...
Searching...
No Matches
_GTestCbmRichDigi.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 "CbmRichDigi.h"
6
7#include "compareRichDigi.h"
8#include "gtest/gtest-spi.h"
9#include "gtest/gtest.h"
10
11TEST(_GTestCbmRichDigi, CheckDefaultConstructor)
12{
13 // Create object
14 CbmRichDigi test;
15
17
18 CbmRichDigi* test1 = new CbmRichDigi();
19
21}
22
23TEST(_GTestCbmRichDigi, CheckStandardConstructor)
24{
25 // Create object
26 CbmRichDigi test(111, 987654321., 23.);
27
28 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
29
30 CbmRichDigi* test1 = new CbmRichDigi(111, 987654321., 23.);
31
32 compareRichDigiDataMembers(*test1, 111, ECbmModuleId::kRich, 987654321., 23.);
33}
34
35TEST(_GTestCbmRichDigi, CheckCopyConstructor)
36{
37 // Create object
38 CbmRichDigi test(111, 987654321., 23.);
39
40 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
41
42 // Create object by copy constructing
43 // test should be equal to test2 and
44 // test should not be changed
45 CbmRichDigi test2 {test};
46
47 compareRichDigiDataMembers(test2, 111, ECbmModuleId::kRich, 987654321., 23.);
48
49 // Test if the original object wasn't changed
50 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
51}
52
53TEST(_GTestCbmRichDigi, CheckAssignmentOperator)
54{
55
56 // Create object
57 CbmRichDigi test(111, 987654321., 23.);
58
59 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
60
61 // Create object by copy assignment
62 // test should be equal to test2 and
63 // test should not be changed
64 CbmRichDigi test2;
65 test2 = test;
66
67 compareRichDigiDataMembers(test2, 111, ECbmModuleId::kRich, 987654321., 23.);
68
69 // Test if the original object wasn't changed
70 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
71}
72
73TEST(_GTestCbmRichDigi, CheckMoveConstructor)
74{
75 // Create object
76 CbmRichDigi test(111, 987654321., 23.);
77
78 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
79
80 // Create object by move constructing
81 CbmRichDigi test2 {std::move(test)};
82
83 compareRichDigiDataMembers(test2, 111, ECbmModuleId::kRich, 987654321., 23.);
84
85 // For objects with simple types move fall back to copy so
86 // the original object is kept unchanged
87 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
88}
89
90TEST(_GTestCbmRichDigi, CheckAssignmentMoveConstructor)
91{
92 // Create object
93 CbmRichDigi test(111, 987654321., 23.);
94
95 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
96
97 // Create object by move constructing
98 CbmRichDigi test2 {};
99 test2 = std::move(test);
100
101 compareRichDigiDataMembers(test2, 111, ECbmModuleId::kRich, 987654321., 23.);
102
103 // For objects with simple types move fall back to copy so
104 // the original object is kept unchanged
105 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
106}
107
108
109TEST(_GTestCbmRichDigi, CheckToString)
110{
111 // Create object
112 CbmRichDigi test(12341234, 987654321., 23.);
113
114 compareRichDigiDataMembers(test, 12341234, ECbmModuleId::kRich, 987654321., 23.);
115
116 EXPECT_STREQ("", test.ToString().c_str());
117}
118
119TEST(_GTestCbmRichDigi, CheckGetClassName)
120{
121 // Create object
122 CbmRichDigi test(111, 987654321., 23.);
123
124 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
125
126 EXPECT_STREQ("CbmRichDigi", test.GetClassName());
127}
128
129TEST(_GTestCbmRichDigi, CheckSetTime)
130{
131 // Create object
132 CbmRichDigi test(111, 987654321., 23.);
133
134 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
135
136 test.SetTime(12345678.);
137
138 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 12345678., 23.);
139}
140
141TEST(_GTestCbmRichDigi, CheckSetAddress)
142{
143 // Create object
144 CbmRichDigi test(111, 987654321., 23.);
145
146 compareRichDigiDataMembers(test, 111, ECbmModuleId::kRich, 987654321., 23.);
147
148 test.SetAddress(12341234);
149
150 compareRichDigiDataMembers(test, 12341234, ECbmModuleId::kRich, 987654321., 23.);
151}
@ kRich
Ring-Imaging Cherenkov Detector.
TEST(_GTestCbmRichDigi, CheckDefaultConstructor)
std::string ToString() const
Definition CbmRichDigi.h:91
static const char * GetClassName()
Class name (static)
Definition CbmRichDigi.h:61
void SetTime(double time)
Definition CbmRichDigi.h:88
void SetAddress(int32_t address)
Definition CbmRichDigi.h:83
void compareRichDigiDataMembers(CbmRichDigi &test, int32_t address, ECbmModuleId systemid, double time, double tot)