CbmRoot
_GTestCbmCluster.cxx
Go to the documentation of this file.
1 #include "CbmCluster.h"
2 
3 #include "CbmMatch.h"
4 
5 #include "gtest/gtest-spi.h"
6 #include "gtest/gtest.h"
7 
8 #include "compareCluster.h"
9 
10 #include <vector>
11 
12 TEST(_GTestCbmCluster, CheckDefaultConstructor) {
13  CbmCluster test;
14  std::vector<Int_t> testvector;
15  {
16  SCOPED_TRACE("CheckDefaultConstructor");
17  compareClusterDataMembers(test, 0, testvector, 0, nullptr);
18  }
19 }
20 
21 TEST(_GTestCbmCluster, CheckStandardConstructor) {
22  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
23  CbmCluster test {testvector, -11};
24  {
25  SCOPED_TRACE("CheckStandardConstructor");
26  compareClusterDataMembers(test, 5, testvector, -11, nullptr);
27  }
28 }
29 
30 TEST(_GTestCbmCluster, CheckSetDigis) {
31  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
32  CbmCluster test {testvector, -11};
33  {
34  SCOPED_TRACE("CheckSetDigis: InitialTest");
35  compareClusterDataMembers(test, 5, testvector, -11, nullptr);
36  }
37 
38  std::vector<Int_t> testvector1 {11, 21, 31, 41, 51, 61};
39  test.SetDigis(testvector1);
40  {
41  SCOPED_TRACE("CheckSetDigis: SetDigis");
42  compareClusterDataMembers(test, 6, testvector1, -11, nullptr);
43  }
44 }
45 
46 TEST(_GTestCbmCluster, CheckAddDigi) {
47  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
48  std::vector<Int_t> testvector1 {1, 2, 3, 4, 5, 111};
49  std::vector<Int_t> testvector2 {1, 2, 3, 4, 5, 111, 222};
50 
51  CbmCluster test {testvector, -11};
52  {
53  SCOPED_TRACE("CheckAddDigi: InitialTest");
55  test, testvector.size(), testvector, -11, nullptr);
56  }
57 
58  test.AddDigi(111);
59  {
60  SCOPED_TRACE("CheckAddDigis: AddDigi 1");
62  test, testvector.size() + 1, testvector1, -11, nullptr);
63  }
64 
65  test.AddDigi(222);
66  {
67  SCOPED_TRACE("CheckAddDigis: AddDigi 2");
69  test, testvector.size() + 2, testvector2, -11, nullptr);
70  }
71 }
72 
73 TEST(_GTestCbmCluster, CheckAddDigis) {
74  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
75  std::vector<Int_t> testvector1 {11, 21, 31, 41, 51, 61};
76  std::vector<Int_t> testvector2 {1, 2, 3, 4, 5, 11, 21, 31, 41, 51, 61};
77 
78  CbmCluster test {testvector, -11};
79  {
80  SCOPED_TRACE("CheckAddDigis: InitialTest");
82  test, testvector.size(), testvector, -11, nullptr);
83  }
84 
85  test.AddDigis(testvector1);
86  {
87  SCOPED_TRACE("CheckAddDigis: AddDigis");
89  test, testvector2.size(), testvector2, -11, nullptr);
90  }
91 }
92 
93 TEST(_GTestCbmCluster, CheckClearDigis) {
94  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
95  std::vector<Int_t> testvector1;
96 
97  CbmCluster test {testvector, -11};
98  {
99  SCOPED_TRACE("CheckClearDigis: InitialTest");
101  test, testvector.size(), testvector, -11, nullptr);
102  }
103 
104  test.ClearDigis();
105  {
106  SCOPED_TRACE("CheckClearDigis: AddDigis");
107  compareClusterDataMembers(test, 0, testvector1, -11, nullptr);
108  }
109 }
110 
111 TEST(_GTestCbmCluster, CheckSetters) {
112  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
113 
114  CbmCluster test {testvector, -11};
115  {
116  SCOPED_TRACE("CheckSetters: InitialTest");
118  test, testvector.size(), testvector, -11, nullptr);
119  }
120 
121  test.SetAddress(-111);
122  {
123  SCOPED_TRACE("CheckSetters: SetAddress");
125  test, testvector.size(), testvector, -111, nullptr);
126  }
127 
128  CbmMatch testMatch;
129  test.SetMatch(&testMatch);
130  {
131  SCOPED_TRACE("CheckSetters: SetAddress");
133  test, testvector.size(), testvector, -111, &testMatch);
134  }
135 }
136 
137 TEST(_GTestCbmCluster, CheckToString) {
138  std::vector<Int_t> testvector {1, 2, 3, 4, 5};
139  CbmCluster test {testvector, -11};
140 
141  EXPECT_STREQ("CbmCluster: nofDigis=5 | 1 2 3 4 5 | address=-11\n",
142  test.ToString().c_str());
143 }
CbmMatch
Definition: CbmMatch.h:22
TEST
TEST(_GTestCbmCluster, CheckDefaultConstructor)
Definition: _GTestCbmCluster.cxx:12
CbmMatch.h
compareClusterDataMembers
void compareClusterDataMembers(CbmCluster &test, Int_t vectorsize, std::vector< Int_t > indices, Int_t address, CbmMatch *match)
Definition: compareCluster.h:9
CbmCluster
Base class for cluster objects.
Definition: CbmCluster.h:26
CbmCluster.h
Base class for cluster objects.
compareCluster.h