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