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