GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by 4c3y (acey) on 06.09.22. |
||
3 |
// |
||
4 |
|||
5 |
#include <gtest/gtest.h> |
||
6 |
#include <test_utils.h> |
||
7 |
#include <log++.h> |
||
8 |
|||
9 |
4 |
TEST(lpp_LogFirstN, lpp_syntax_severity_debug) { |
|
10 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
11 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(D, 3, "Test" << 123)); |
12 |
|||
13 |
✓✓ | 10 |
if (i < 3) { |
14 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "DEBUG Test123\n"); |
15 |
} else { |
||
16 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
17 |
} |
||
18 |
} |
||
19 |
} |
||
20 |
|||
21 |
4 |
TEST(lpp_LogFirstN, lpp_syntax_severity_info) { |
|
22 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
23 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(I, 3, "Test" << 123)); |
24 |
|||
25 |
✓✓ | 10 |
if (i < 3) { |
26 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "INFO Test123\n"); |
27 |
} else { |
||
28 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
29 |
} |
||
30 |
} |
||
31 |
} |
||
32 |
|||
33 |
4 |
TEST(lpp_LogFirstN, lpp_syntax_severity_warning) { |
|
34 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
35 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(W, 3, "Test" << 123)); |
36 |
|||
37 |
✓✓ | 10 |
if (i < 3) { |
38 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "WARN Test123\n"); |
39 |
} else { |
||
40 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
41 |
} |
||
42 |
} |
||
43 |
} |
||
44 |
|||
45 |
4 |
TEST(lpp_LogFirstN, lpp_syntax_severity_error) { |
|
46 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
47 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(E, 3, "Test" << 123)); |
48 |
|||
49 |
✓✓ | 10 |
if (i < 3) { |
50 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "ERROR Test123\n"); |
51 |
} else { |
||
52 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
53 |
} |
||
54 |
} |
||
55 |
} |
||
56 |
|||
57 |
4 |
TEST(lpp_LogFirstN, lpp_syntax_severity_fatal) { |
|
58 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
59 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(F, 3, "Test" << 123)); |
60 |
|||
61 |
✓✓ | 10 |
if (i < 3) { |
62 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "FATAL Test123\n"); |
63 |
} else { |
||
64 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
65 |
} |
||
66 |
} |
||
67 |
} |
||
68 |
|||
69 |
4 |
TEST(lpp_LogFirstN, glog_syntax_severity_debug) { |
|
70 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
71 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(DLOG_FIRST_N(INFO, 3) << "Test" << 123); |
72 |
|||
73 |
✓✓ | 10 |
if (i < 3) { |
74 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "DEBUG Test123\n"); |
75 |
} else { |
||
76 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
77 |
} |
||
78 |
} |
||
79 |
} |
||
80 |
|||
81 |
4 |
TEST(lpp_LogFirstN, glog_syntax_severity_info) { |
|
82 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
83 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST_N(INFO, 3) << "Test" << 123); |
84 |
|||
85 |
✓✓ | 10 |
if (i < 3) { |
86 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "INFO Test123\n"); |
87 |
} else { |
||
88 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
89 |
} |
||
90 |
} |
||
91 |
} |
||
92 |
|||
93 |
4 |
TEST(lpp_LogFirstN, glog_syntax_severity_warning) { |
|
94 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
95 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST_N(WARNING, 3) << "Test" << 123); |
96 |
|||
97 |
✓✓ | 10 |
if (i < 3) { |
98 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "WARN Test123\n"); |
99 |
} else { |
||
100 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
101 |
} |
||
102 |
} |
||
103 |
} |
||
104 |
|||
105 |
4 |
TEST(lpp_LogFirstN, glog_syntax_severity_error) { |
|
106 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
107 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST_N(ERROR, 3) << "Test" << 123); |
108 |
|||
109 |
✓✓ | 10 |
if (i < 3) { |
110 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "ERROR Test123\n"); |
111 |
} else { |
||
112 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
113 |
} |
||
114 |
} |
||
115 |
} |
||
116 |
|||
117 |
4 |
TEST(lpp_LogFirstN, glog_syntax_severity_fatal) { |
|
118 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
119 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST_N(FATAL, 3) << "Test" << 123); |
120 |
|||
121 |
✓✓ | 10 |
if (i < 3) { |
122 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "FATAL Test123\n"); |
123 |
} else { |
||
124 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
125 |
} |
||
126 |
} |
||
127 |
} |
||
128 |
|||
129 |
4 |
TEST(lpp_LogFirstN, ros_debug_once) { |
|
130 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
131 |
|||
132 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
133 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(ROS_DEBUG_ONCE("Test123")); |
134 |
|||
135 |
✓✓ | 10 |
if (i == 0) { |
136 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "DEBUG Test123\n"); |
137 |
} else { |
||
138 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ("", output); |
139 |
} |
||
140 |
} |
||
141 |
} |
||
142 |
|||
143 |
4 |
TEST(lpp_LogFirstN, ros_info_once) { |
|
144 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
145 |
|||
146 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
147 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(ROS_INFO_ONCE("Test123")); |
148 |
|||
149 |
✓✓ | 10 |
if (i == 0) { |
150 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "INFO Test123\n"); |
151 |
} else { |
||
152 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ("", output); |
153 |
} |
||
154 |
} |
||
155 |
} |
||
156 |
|||
157 |
4 |
TEST(lpp_LogFirstN, ros_warn_once) { |
|
158 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
159 |
|||
160 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
161 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(ROS_WARN_ONCE("Test123")); |
162 |
|||
163 |
✓✓ | 10 |
if (i == 0) { |
164 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "WARN Test123\n"); |
165 |
} else { |
||
166 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ("", output); |
167 |
} |
||
168 |
} |
||
169 |
} |
||
170 |
|||
171 |
4 |
TEST(lpp_LogFirstN, ros_error_once) { |
|
172 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
173 |
|||
174 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
175 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(ROS_ERROR_ONCE("Test123")); |
176 |
|||
177 |
✓✓ | 10 |
if (i == 0) { |
178 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "ERROR Test123\n"); |
179 |
} else { |
||
180 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ("", output); |
181 |
} |
||
182 |
} |
||
183 |
} |
||
184 |
|||
185 |
2 |
TEST(lpp_LogFirstN, ros_fatal_once) { |
|
186 |
1 |
LOG_INIT(*test_argv); |
|
187 |
|||
188 |
6 |
for (int i = 0; i < 5; i++) { |
|
189 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
10 |
std::string output = LPP_CAPTURE_STDOUT(ROS_FATAL_ONCE("Test123")); |
190 |
|||
191 |
5 |
if (i == 0) { |
|
192 |
1 |
ASSERT_EQ(output, "FATAL Test123\n"); |
|
193 |
} else { |
||
194 |
4 |
ASSERT_EQ("", output); |
|
195 |
} |
||
196 |
} |
||
197 |
} |
||
198 |
Generated by: GCOVR (Version 4.2) |