CbmRoot
Loading...
Searching...
No Matches
_GTestCbmBmonDigi.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#include "CbmBmonDigi.h"
6
7#include "compareBmonDigi.h"
8#include "gtest/gtest-spi.h"
9#include "gtest/gtest.h"
10
11TEST(_GTestCbmBmonDigi, CheckDefaultConstructor)
12{
13 // Create object
14 CbmBmonDigi test;
15
17
18 CbmBmonDigi* test1 = new CbmBmonDigi();
19
21}
22
23TEST(_GTestCbmBmonDigi, CheckStandardConstructor)
24{
25 // Create object
26 CbmBmonDigi test(111, 987654321., 23.);
27
28 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
29
30 CbmBmonDigi* test1 = new CbmBmonDigi(111, 987654321., 23.);
31
32 compareBmonDigiDataMembers(*test1, 111, ECbmModuleId::kBmon, 987654321., 23.);
33}
34
35TEST(_GTestCbmBmonDigi, CheckCopyConstructor)
36{
37 // Create object
38 CbmBmonDigi test(111, 987654321., 23.);
39
40 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
41
42 // Create object by copy constructing
43 // test should be equal to test2 and
44 // test should not be changed
45 CbmBmonDigi test2 {test};
46
47 compareBmonDigiDataMembers(test2, 111, ECbmModuleId::kBmon, 987654321., 23.);
48
49 // Test if the original object wasn't changed
50 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
51}
52
53TEST(_GTestCbmBmonDigi, CheckAssignmentOperator)
54{
55
56 // Create object
57 CbmBmonDigi test(111, 987654321., 23.);
58
59 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
60
61 // Create object by copy assignment
62 // test should be equal to test2 and
63 // test should not be changed
64 CbmBmonDigi test2;
65 test2 = test;
66
67 compareBmonDigiDataMembers(test2, 111, ECbmModuleId::kBmon, 987654321., 23.);
68
69 // Test if the original object wasn't changed
70 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
71}
72
73TEST(_GTestCbmBmonDigi, CheckMoveConstructor)
74{
75 // Create object
76 CbmBmonDigi test(111, 987654321., 23.);
77
78 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
79
80 // Create object by move constructing
81 CbmBmonDigi test2 {std::move(test)};
82
83 compareBmonDigiDataMembers(test2, 111, ECbmModuleId::kBmon, 987654321., 23.);
84
85 // For objects with simple types move fall back to copy so
86 // the original object is kept unchanged
87 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
88}
89
90TEST(_GTestCbmBmonDigi, CheckAssignmentMoveConstructor)
91{
92 // Create object
93 CbmBmonDigi test(111, 987654321., 23.);
94
95 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
96
97 // Create object by move constructing
98 CbmBmonDigi test2 {};
99 test2 = std::move(test);
100
101 compareBmonDigiDataMembers(test2, 111, ECbmModuleId::kBmon, 987654321., 23.);
102
103 // For objects with simple types move fall back to copy so
104 // the original object is kept unchanged
105 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
106}
107
108TEST(_GTestCbmBmonDigi, CheckGetClassName)
109{
110 // Create object
111 CbmBmonDigi test(111, 987654321., 23.);
112
113 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
114
115 EXPECT_STREQ("CbmBmonDigi", test.GetClassName());
116}
117
118TEST(_GTestCbmBmonDigi, CheckSetTime)
119{
120 // Create object
121 CbmBmonDigi test(111, 987654321., 23.);
122
123 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
124
125 test.SetTime(12345678.);
126
127 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 12345678., 23.);
128}
129
130TEST(_GTestCbmBmonDigi, CheckSetAddress)
131{
132 // Create object
133 CbmBmonDigi test(111, 987654321., 23.);
134
135 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
136
137 test.SetAddress(12341234);
138
139 compareBmonDigiDataMembers(test, 12341234, ECbmModuleId::kBmon, 987654321., 23.);
140}
141
142TEST(_GTestCbmBmonDigi, CheckSetCharge)
143{
144 // Create object
145 CbmBmonDigi test(111, 987654321., 23.);
146
147 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 23.);
148
149 test.SetCharge(45.);
150
151 compareBmonDigiDataMembers(test, 111, ECbmModuleId::kBmon, 987654321., 45.);
152}
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
TEST(_GTestCbmBmonDigi, CheckDefaultConstructor)
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:30
void SetCharge(float charge)
Set the measured charge.
void SetAddress(int32_t addr)
Set the address.
Definition CbmBmonDigi.h:98
static const char * GetClassName()
Class name (static)
Definition CbmBmonDigi.h:69
void SetTime(double time)
Set the measurement time.
void compareBmonDigiDataMembers(CbmBmonDigi &test, int32_t address, ECbmModuleId systemid, double time, double charge)