CbmRoot
Loading...
Searching...
No Matches
_GTestCbmPsdHit.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmPsdHit.h"
6
7#include "comparePsdHit.h"
8#include "gtest/gtest-spi.h"
9#include "gtest/gtest.h"
10
11TEST(_GTestCbmPsdHit, CheckDefaultConstructor)
12{
13 // Create object
14 CbmPsdHit test;
15
16 comparePsdHitDataMembers(test, -1, -1.);
17
18 CbmPsdHit* test1 = new CbmPsdHit();
19
20 comparePsdHitDataMembers(*test1, -1, -1.);
21}
22
23TEST(_GTestCbmPsdHit, CheckStandardConstructor)
24{
25 // Create object
26 CbmPsdHit test(5, 6.7);
27
28 comparePsdHitDataMembers(test, 5, 6.7);
29
30 CbmPsdHit* test1 = new CbmPsdHit(2, 8.9);
31
32 comparePsdHitDataMembers(*test1, 2, 8.9);
33}
34
35TEST(_GTestCbmPsdHit, CheckCopyConstructor)
36{
37 // Create object
38 CbmPsdHit test(5, 6.7);
39
40 comparePsdHitDataMembers(test, 5, 6.7);
41
42 // Create object by copy constructing
43 // test should be equal to test2 and
44 // test should not be changed
45 CbmPsdHit test2 {test};
46
47 comparePsdHitDataMembers(test2, 5, 6.7);
48
49 // Test if the original object wasn't changed
50 comparePsdHitDataMembers(test, 5, 6.7);
51}
52
53TEST(_GTestCbmPsdHit, CheckAssignmentOperator)
54{
55 // Create object
56 CbmPsdHit test(5, 6.7);
57
58 comparePsdHitDataMembers(test, 5, 6.7);
59
60 // Create object by copy constructing
61 // test should be equal to test2 and
62 // test should not be changed
63 CbmPsdHit test2 {};
64 test2 = test;
65
66 comparePsdHitDataMembers(test2, 5, 6.7);
67
68 // Test if the original object wasn't changed
69 comparePsdHitDataMembers(test, 5, 6.7);
70}
71
72TEST(_GTestCbmPsdHit, CheckMoveConstructor)
73{
74 // Create object
75 CbmPsdHit test(5, 6.7);
76
77 comparePsdHitDataMembers(test, 5, 6.7);
78
79 // Create object by copy constructing
80 // test should be equal to test2 and
81 // test should not be changed
82 CbmPsdHit test2 {std::move(test)};
83
84 comparePsdHitDataMembers(test2, 5, 6.7);
85
86 // For objects with simple types move fall back to copy so
87 // the original object is kept unchanged
88 comparePsdHitDataMembers(test, 5, 6.7);
89}
90
91TEST(_GTestCbmPsdHit, CheckAssignmentMoveConstructor)
92{
93 // Create object
94 CbmPsdHit test(5, 6.7);
95
96 comparePsdHitDataMembers(test, 5, 6.7);
97
98 // Create object by copy constructing
99 // test should be equal to test2 and
100 // test should not be changed
101 CbmPsdHit test2 {};
102 test2 = std::move(test);
103
104 comparePsdHitDataMembers(test2, 5, 6.7);
105
106 // For objects with simple types move fall back to copy so
107 // the original object is kept unchanged
108 comparePsdHitDataMembers(test, 5, 6.7);
109}
110
111
112TEST(_GTestCbmPsdHit, CheckPrint)
113{
114 // Create object
115 CbmPsdHit test(5, 6.7);
116
117 comparePsdHitDataMembers(test, 5, 6.7);
118
119 testing::internal::CaptureStdout();
120 test.Print("");
121 std::string output = testing::internal::GetCapturedStdout();
122
123 EXPECT_STREQ("[INFO] module : 5 ELoss 6.7\n", output.c_str());
124}
TEST(_GTestCbmPsdHit, CheckDefaultConstructor)
void Print(Option_t *="") const
Definition CbmPsdHit.cxx:38
void comparePsdHitDataMembers(CbmPsdHit &test, int32_t moduleid, double edep)