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