CbmRoot
_GTestCbmLink.cxx
Go to the documentation of this file.
1 #include "CbmLink.h"
2 
3 #include "gtest/gtest-spi.h"
4 #include "gtest/gtest.h"
5 
6 //define functions which does the comparision
7 #include "compareLink.h"
8 
9 TEST(_GTestCbmLink, CheckDefaultConstructor) {
10  CbmLink test;
11  {
12  SCOPED_TRACE("CheckDefaultConstructor");
13  compareLinkDataMembers(test, -1, -1, -1, -1.);
14  }
15 }
16 
17 TEST(_GTestCbmLink, CheckStandardConstructor1) {
18  CbmLink test {-2., -2};
19  {
20  SCOPED_TRACE("CheckStandardConstructor1");
21  compareLinkDataMembers(test, -1, -1, -2, -2.);
22  }
23 }
24 
25 TEST(_GTestCbmLink, CheckStandardConstructor2) {
26  CbmLink test {-2., -2, -2, -2};
27  {
28  SCOPED_TRACE("CheckStandardConstructor2");
29  compareLinkDataMembers(test, -2, -2, -2, -2.);
30  }
31 }
32 
33 TEST(_GTestCbmLink, TestSettersAndGetters) {
34  CbmLink test {-2., -2, -2, -2};
35  {
36  SCOPED_TRACE("TestSettersAndGetters: Initial test");
37  compareLinkDataMembers(test, -2, -2, -2, -2.);
38  }
39 
40  test.SetFile(-3);
41  {
42  SCOPED_TRACE("TestSettersAndGetters: Test SetFile");
43  compareLinkDataMembers(test, -3, -2, -2, -2.);
44  }
45 
46  test.SetEntry(-3);
47  {
48  SCOPED_TRACE("TestSettersAndGetters: Test SetEntry");
49  compareLinkDataMembers(test, -3, -3, -2, -2.);
50  }
51 
52  test.SetIndex(-3);
53  {
54  SCOPED_TRACE("TestSettersAndGetters: Test SetIndex");
55  compareLinkDataMembers(test, -3, -3, -3, -2.);
56  }
57 
58  test.SetWeight(-3.);
59  {
60  SCOPED_TRACE("TestSettersAndGetters: Test SetWeight");
61  compareLinkDataMembers(test, -3, -3, -3, -3.);
62  }
63 
64  test.AddWeight(-3);
65  {
66  SCOPED_TRACE("TestSettersAndGetters: Test AddWeight");
67  compareLinkDataMembers(test, -3, -3, -3, -6.);
68  }
69 }
70 
71 TEST(_GTestCbmLink, ToString) {
72  CbmLink test {-2., -2, -2, -2};
73  EXPECT_STREQ("CbmLink: weight=-2 index=-2 entry=-2 file=-2\n",
74  test.ToString().c_str());
75 }
76 
77 
78 TEST(_GTestCbmLink, CompareEqual) {
79  CbmLink test {-2., -2, -2, -2};
80  CbmLink test1 {-2., -2, -2, -2};
81  CbmLink test2 {-1., -2, -2, -2};
82  CbmLink test3 {-2., -1, -2, -2};
83  CbmLink test4 {-2., -2, -1, -2};
84  CbmLink test5 {-2., -2, -2, -1};
85 
86  EXPECT_TRUE(test == test1);
87  EXPECT_TRUE(
88  test
89  == test2); //equals only check file, entry, and index ids but not the weight
90  EXPECT_FALSE(test == test3);
91  EXPECT_FALSE(test == test4);
92  EXPECT_FALSE(test == test5);
93 }
94 
95 TEST(_GTestCbmLink, CompareGreater) {
96  CbmLink test {2., 2, 2, 2};
97  CbmLink test1 {2., 2, 2, 2};
98  CbmLink test2 {2., 1, 2, 2};
99  CbmLink test3 {2., 2, 1, 2};
100  CbmLink test4 {2., 2, 2, 1};
101 
102  EXPECT_FALSE(test > test1);
103  EXPECT_TRUE(test > test2);
104  EXPECT_FALSE(test2 > test);
105  EXPECT_TRUE(test > test3);
106  EXPECT_FALSE(test3 > test);
107  EXPECT_TRUE(test > test4);
108  EXPECT_FALSE(test4 > test);
109 }
110 
111 TEST(_GTestCbmLink, CompareSmaller) {
112  CbmLink test {2., 2, 2, 2};
113  CbmLink test1 {2., 2, 2, 2};
114  CbmLink test2 {2., 1, 2, 2};
115  CbmLink test3 {2., 2, 1, 2};
116  CbmLink test4 {2., 2, 2, 1};
117 
118  EXPECT_FALSE(test < test1);
119  EXPECT_FALSE(test < test2);
120  EXPECT_TRUE(test2 < test);
121  EXPECT_FALSE(test < test3);
122  EXPECT_TRUE(test3 < test);
123  EXPECT_FALSE(test < test4);
124  EXPECT_TRUE(test4 < test);
125 }
Cbm::ToString
std::string ToString(const T &value)
Definition: CbmUtils.h:16