3 #include <FairLogger.h>
5 #include <TMatrixTSym.h>
8 #include <gtest/gtest-spi.h>
9 #include <gtest/gtest.h>
13 #include "../compareVertex.h"
15 TEST(_GTestCbmVertex, CheckDefaultConstructor) {
17 Double_t val[6] = {0., 0., 0., 0., 0., 0.};
19 SCOPED_TRACE(
"CheckDefaultConstructor");
24 TEST(_GTestCbmVertex, CheckStandardConstructor) {
26 Double_t val[6] = {0., 0., 0., 0., 0., 0.};
28 SCOPED_TRACE(
"CheckStandardConstructor");
33 TEST(_GTestCbmVertex, CheckConstructorAllArguments) {
45 Double_t val[6] = {0., 1., 2., 3., 4., 5.};
46 CbmVertex test {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, Cov};
48 SCOPED_TRACE(
"CheckConstructorAllArguments");
55 TMatrixFSym CovWrong(2);
61 Double_t
val1[6] = {0., 0., 0., 0., 0., 0.};
63 testing::internal::CaptureStdout();
64 CbmVertex test1 {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, CovWrong};
65 std::string output = testing::internal::GetCapturedStdout();
67 std::regex
f(
"\\[ERROR(.*)\\](.*)(Wrong dimension of passed covariance "
68 "matrix\\. Clear the covariance matrix)(.*)\\n");
69 bool retval = std::regex_match(output,
f);
71 std::cout <<
" Actual: " << output << std::endl;
72 std::cout <<
"Expected: "
73 <<
"\\[ERROR\\](.*)(Wrong dimension of passed covariance "
74 "matrix\\. Clear the covariance matrix)(.*)\\n"
80 SCOPED_TRACE(
"CheckConstructorAllArgumentsWrongCovMatrix");
85 TEST(_GTestCbmVertex, CheckReset) {
97 Double_t val[6] = {0., 1., 2., 3., 4., 5.};
98 CbmVertex test {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, Cov};
100 SCOPED_TRACE(
"CheckReset: Initial Test");
104 Double_t
val1[6] = {0., 0., 0., 0., 0., 0.};
107 SCOPED_TRACE(
"CheckReset: Check after reset");
112 TEST(_GTestCbmVertex, CheckGetPosition) {
124 Double_t val[6] = {0., 1., 2., 3., 4., 5.};
125 CbmVertex test {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, Cov};
127 SCOPED_TRACE(
"CheckGetPosition: Initial Test");
133 test.Position(testVect);
135 SCOPED_TRACE(
"CheckGetPosition: Check after Position");
138 EXPECT_FLOAT_EQ(1., testVect.X());
139 EXPECT_FLOAT_EQ(2., testVect.Y());
140 EXPECT_FLOAT_EQ(3., testVect.Z());
144 TEST(_GTestCbmVertex, CheckGetCovMatrix) {
156 Double_t val[6] = {0., 1., 2., 3., 4., 5.};
157 CbmVertex test {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, Cov};
159 SCOPED_TRACE(
"CheckGetCovMatrix: Initial Test");
163 TMatrixFSym testCov(3);
165 test.CovMatrix(testCov);
167 SCOPED_TRACE(
"CheckGetCovMatrix: Check after Position");
170 for (Int_t
i = 0;
i < 3; ++
i) {
171 for (Int_t j = 0; j < 3; ++j) {
172 Double_t origVal = Cov[
i][j];
173 Double_t testVal = testCov[
i][j];
174 EXPECT_FLOAT_EQ(testVal, origVal);
180 TEST(_GTestCbmVertex, CheckSetVertex) {
183 Double_t val[6] = {0., 0., 0., 0., 0., 0.};
185 SCOPED_TRACE(
"CheckSetVertex: Initial Test");
200 Double_t
val1[6] = {0., 1., 2., 3., 4., 5.};
201 test.
SetVertex(1., 2., 3., 4., 5, 6, Cov);
203 SCOPED_TRACE(
"CheckSetVertex: After call of SetVertex");
210 TMatrixFSym CovWrong(2);
216 Double_t
val2[6] = {0., 0., 0., 0., 0., 0.};
218 testing::internal::CaptureStdout();
219 test.
SetVertex(-1., -2., -3., -4., -5, -6, CovWrong);
220 std::string output = testing::internal::GetCapturedStdout();
222 std::regex
f(
"\\[ERROR(.*)\\](.*)(Wrong dimension of passed covariance "
223 "matrix\\. Clear the covariance matrix)(.*)\\n");
224 bool retval = std::regex_match(output,
f);
226 std::cout <<
" Actual: " << output << std::endl;
227 std::cout <<
"Expected: "
228 <<
"\\[ERROR\\](.*)(Wrong dimension of passed covariance "
229 "matrix\\. Clear the covariance matrix)(.*)\\n"
235 SCOPED_TRACE(
"CheckSetVertex: Check after SetVertex with wrong cov matrix");
240 TEST(_GTestCbmVertex, CheckPrint) {
252 Double_t val[6] = {0., 1., 2., 3., 4., 5.};
253 CbmVertex test {
"Vertex",
"Vertex", 1., 2., 3., 4., 5, 6, Cov};
255 SCOPED_TRACE(
"CheckSetVertex: Initial Test");
259 EXPECT_STREQ(
"Vertex: position (1.0000, 2.0000, 3.0000) cm, chi2/ndf = "
260 "0.8000, tracks used: 6",
261 test.ToString().c_str());
264 CbmVertex test1 {
"Vertex",
"Vertex", 1., 2., 3., 4., 0, 6, Cov};
266 SCOPED_TRACE(
"CheckSetVertex: Initial Test");
270 EXPECT_STREQ(
"Vertex: position (1.0000, 2.0000, 3.0000) cm, chi2/ndf = "
271 "0.0000, tracks used: 6",
272 test1.ToString().c_str());