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