CbmRoot
_GTestCbmStsDigi.cxx
Go to the documentation of this file.
1 #include "CbmStsDigi.h"
2 
3 #include "gtest/gtest-spi.h"
4 #include "gtest/gtest.h"
5 
6 #include "compareStsDigi.h"
7 
8 TEST(_GTestCbmStsDigi, CheckDefaultConstructor) {
9  // Create object
10  CbmStsDigi test;
11 
13 
14  CbmStsDigi* test1 = new CbmStsDigi();
15 
16  compareStsDigiDataMembers(*test1, 0, 0, 0, ECbmModuleId::kSts, 0);
17 }
18 
19 TEST(_GTestCbmStsDigi, CheckStandardConstructor) {
20  // Create object
21  CbmStsDigi test(111, 42, 987654321, 23);
22 
23  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
24 
25  CbmStsDigi* test1 = new CbmStsDigi(111, 42, 897654321, 23);
26 
27  compareStsDigiDataMembers(*test1, 111, 23, 42, ECbmModuleId::kSts, 897654321);
28 }
29 
30 TEST(_GTestCbmStsDigi, CheckCopyConstructor) {
31  // Create object
32  CbmStsDigi test(111, 42, 987654321, 23);
33 
34  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
35 
36  // Create object by copy constructing
37  // test should be equal to test2 and
38  // test should not be changed
39  CbmStsDigi test2 {test};
40 
41  compareStsDigiDataMembers(test2, 111, 23, 42, ECbmModuleId::kSts, 987654321);
42 
43  // Test if the original object wasn't changed
44  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
45 }
46 
47 TEST(_GTestCbmStsDigi, CheckAssignmentOperator) {
48 
49  // Create object
50  CbmStsDigi test(111, 42, 987654321, 23);
51 
52  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
53 
54  // Create object by copy assignment
55  // test should be equal to test2 and
56  // test should not be changed
57  CbmStsDigi test2;
58  test2 = test;
59 
60  compareStsDigiDataMembers(test2, 111, 23, 42, ECbmModuleId::kSts, 987654321);
61 
62  // Test if the original object wasn't changed
63  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
64 }
65 
66 TEST(_GTestCbmStsDigi, CheckMoveConstructor) {
67  // Create object
68  CbmStsDigi test(111, 42, 987654321, 23);
69 
70  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
71 
72  // Create object by move constructing
73  CbmStsDigi test2 {std::move(test)};
74 
75  compareStsDigiDataMembers(test2, 111, 23, 42, ECbmModuleId::kSts, 987654321);
76 
77  // For objects with simple types move fall back to copy so
78  // the original object is kept unchanged
79  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
80 }
81 
82 TEST(_GTestCbmStsDigi, CheckAssignmentMoveConstructor) {
83  // Create object
84  CbmStsDigi test(111, 42, 987654321, 23);
85 
86  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
87 
88  // Create object by move constructing
89  CbmStsDigi test2 {};
90  test2 = std::move(test);
91 
92  compareStsDigiDataMembers(test2, 111, 23, 42, ECbmModuleId::kSts, 987654321);
93 
94  // For objects with simple types move fall back to copy so
95  // the original object is kept unchanged
96  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
97 }
98 
99 TEST(_GTestCbmStsDigi, CheckSetTime) {
100  // Create object
101  CbmStsDigi test(111, 42, 987654321, 23);
102 
103  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
104 
105  test.SetTime(897654321.0);
106 
107  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 897654321);
108 }
109 
110 TEST(_GTestCbmStsDigi, CheckToString) {
111  CbmStsDigi test(111, 42, 987654321, 23);
112 
113  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
114 
115  EXPECT_STREQ("StsDigi: address 111 | channel 42 | charge 23 | time 987654321",
116  test.ToString().c_str());
117 }
118 
119 TEST(_GTestCbmStsDigi, CheckGetClassName) {
120  CbmStsDigi test(111, 42, 987654321, 23);
121 
122  compareStsDigiDataMembers(test, 111, 23, 42, ECbmModuleId::kSts, 987654321);
123 
124  EXPECT_STREQ("CbmStsDigi", test.GetClassName());
125 }
CbmStsDigi::GetClassName
static const char * GetClassName()
Class name (static)
Definition: CbmStsDigi.h:65
CbmStsDigi::ToString
std::string ToString() const
Definition: CbmStsDigi.cxx:15
compareStsDigiDataMembers
void compareStsDigiDataMembers(CbmStsDigi &test, Int_t address, UShort_t charge, UShort_t channel, ECbmModuleId systemid, Long64_t time)
Definition: compareStsDigi.h:4
CbmStsDigi.h
CbmStsDigi
Data class for a single-channel message in the STS.
Definition: CbmStsDigi.h:29
CbmStsDigi::SetTime
void SetTime(Double_t dNewTime)
Definition: CbmStsDigi.h:98
compareStsDigi.h
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
TEST
TEST(_GTestCbmStsDigi, CheckDefaultConstructor)
Definition: _GTestCbmStsDigi.cxx:8