GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by acey on 23.08.22. |
||
3 |
// |
||
4 |
|||
5 |
#include "test_utils.h" |
||
6 |
#include <gtest/gtest.h> |
||
7 |
#include <log++.h> |
||
8 |
|||
9 |
//! ################ glog ################ |
||
10 |
|||
11 |
4 |
TEST(glog_basic, glog_syntax_severity_debug) { |
|
12 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
13 |
|||
14 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(DLOG(INFO) << "xyz"); |
15 |
|||
16 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "xyz")); |
17 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
18 |
|||
19 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
20 |
} |
||
21 |
|||
22 |
4 |
TEST(glog_basic, glog_syntax_severity_info) { |
|
23 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
24 |
|||
25 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(INFO) << "xyz"); |
26 |
|||
27 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "xyz")); |
28 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
29 |
|||
30 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
31 |
} |
||
32 |
|||
33 |
4 |
TEST(glog_basic, glog_syntax_severity_warning) { |
|
34 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
35 |
|||
36 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(WARNING) << "xyz"); |
37 |
|||
38 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "xyz")); |
39 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
40 |
|||
41 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'W'); |
42 |
} |
||
43 |
|||
44 |
4 |
TEST(glog_basic, glog_syntax_severity_error) { |
|
45 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
46 |
|||
47 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(ERROR) << "xyz"); |
48 |
|||
49 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "xyz")); |
50 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
51 |
|||
52 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'E'); |
53 |
} |
||
54 |
|||
55 |
4 |
TEST(glog_basic, glog_syntax_severity_fatal) { |
|
56 |
|||
57 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
58 |
|||
59 |
std::function<void()> fn = []() { |
||
60 |
std::string output = LPP_CAPTURE_STDERR(LOG(FATAL) << "xyz"); |
||
61 |
|||
62 |
ASSERT_TRUE(isSubstring(output, "xyz")); |
||
63 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
||
64 |
|||
65 |
ASSERT_EQ(output[0], 'F'); |
||
66 |
✓✗ | 2 |
}; |
67 |
|||
68 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_TRUE(checkAbort(fn)); |
69 |
} |
||
70 |
|||
71 |
|||
72 |
//! ################ lpp ################ |
||
73 |
|||
74 |
4 |
TEST(glog_basic, lpp_syntax_severity_debug) { |
|
75 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
76 |
|||
77 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(D, "Test" << "123")); |
78 |
|||
79 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
80 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
81 |
|||
82 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_TRUE(output[0] == 'I'); |
83 |
} |
||
84 |
|||
85 |
4 |
TEST(glog_basic, lpp_syntax_severity_info) { |
|
86 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
87 |
|||
88 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(I, "Test" << 123)); |
89 |
|||
90 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
91 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
92 |
|||
93 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_TRUE(output[0] == 'I'); |
94 |
} |
||
95 |
|||
96 |
4 |
TEST(glog_basic, lpp_syntax_severity_warning) { |
|
97 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
98 |
|||
99 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(W, "Test" << 123)); |
100 |
|||
101 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
102 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
103 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'W'); |
104 |
} |
||
105 |
|||
106 |
4 |
TEST(glog_basic, lpp_syntax_severity_error) { |
|
107 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
108 |
|||
109 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG(E, "Test" << 123)); |
110 |
|||
111 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
112 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
113 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'E'); |
114 |
} |
||
115 |
|||
116 |
4 |
TEST(glog_basic, lpp_syntax_severity_fatal) { |
|
117 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
118 |
|||
119 |
std::function<void()> fn = []() { |
||
120 |
testing::internal::CaptureStderr(); |
||
121 |
LOG(F, "Test" << "123"); |
||
122 |
std::string output = testing::internal::GetCapturedStderr(); |
||
123 |
|||
124 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
||
125 |
ASSERT_TRUE(output[0] == 'F'); |
||
126 |
✓✗ | 2 |
}; |
127 |
|||
128 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_TRUE(checkAbort(fn)); |
129 |
} |
||
130 |
|||
131 |
|||
132 |
//! ################ Roslog ################ |
||
133 |
4 |
TEST(glog_basic, roslog_syntax_severity_debug) { |
|
134 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
135 |
|||
136 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_DEBUG("Test123")); |
137 |
|||
138 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
139 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
140 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
141 |
} |
||
142 |
|||
143 |
4 |
TEST(glog_basic, roslog_syntax_severity_debug_stream) { |
|
144 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
145 |
|||
146 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_DEBUG_STREAM("Test123")); |
147 |
|||
148 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
149 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
150 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
151 |
} |
||
152 |
|||
153 |
4 |
TEST(glog_basic, roslog_syntax_severity_info) { |
|
154 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
155 |
|||
156 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_INFO("Test123")); |
157 |
|||
158 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
159 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
160 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
161 |
} |
||
162 |
|||
163 |
4 |
TEST(glog_basic, roslog_syntax_severity_info_stream) { |
|
164 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
165 |
|||
166 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_INFO_STREAM("Test" << 123)); |
167 |
|||
168 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
169 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
170 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
171 |
} |
||
172 |
|||
173 |
4 |
TEST(glog_basic, roslog_syntax_severity_warn) { |
|
174 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
175 |
|||
176 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_WARN("Test123")); |
177 |
|||
178 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
179 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
180 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'W'); |
181 |
} |
||
182 |
|||
183 |
4 |
TEST(glog_basic, roslog_syntax_severity_warn_stream) { |
|
184 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
185 |
|||
186 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_WARN_STREAM("Test" << 123)); |
187 |
|||
188 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
189 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
190 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'W'); |
191 |
} |
||
192 |
|||
193 |
4 |
TEST(glog_basic, roslog_syntax_severity_error) { |
|
194 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
195 |
|||
196 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_ERROR("Test123")); |
197 |
|||
198 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
199 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
200 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'E'); |
201 |
} |
||
202 |
|||
203 |
4 |
TEST(glog_basic, roslog_syntax_severity_error_stream) { |
|
204 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
205 |
|||
206 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(ROS_ERROR_STREAM("Test" << 123)); |
207 |
|||
208 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
209 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
210 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'E'); |
211 |
} |
||
212 |
|||
213 |
4 |
TEST(glog_basic, roslog_syntax_severity_fatal) { |
|
214 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
215 |
|||
216 |
std::function<void()> fn = []() { |
||
217 |
std::string output = LPP_CAPTURE_STDERR(ROS_FATAL("Test123")); |
||
218 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
||
219 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
||
220 |
ASSERT_EQ(output[0], 'F'); |
||
221 |
✓✗ | 2 |
}; |
222 |
|||
223 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
2 |
ASSERT_TRUE(checkAbort(fn)); |
224 |
} |
||
225 |
|||
226 |
2 |
TEST(glog_basic, roslog_syntax_severity_fatal_stream) { |
|
227 |
1 |
LOG_INIT(*test_argv); |
|
228 |
|||
229 |
std::function<void()> fn = []() { |
||
230 |
std::string output = LPP_CAPTURE_STDERR(ROS_FATAL_STREAM("Test" << 123)); |
||
231 |
|||
232 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
||
233 |
ASSERT_TRUE(isSubstring(output, "test_glog_basic.cc")); |
||
234 |
ASSERT_EQ(output[0], 'F'); |
||
235 |
1 |
}; |
|
236 |
1 |
ASSERT_TRUE(checkAbort(fn)); |
|
237 |
} |
Generated by: GCOVR (Version 4.2) |