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