GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by 4c3y (acey) on 27.09.22. |
||
3 |
// |
||
4 |
|||
5 |
#include <gtest/gtest.h> |
||
6 |
#include "log++.h" |
||
7 |
#include "test_utils.h" |
||
8 |
|||
9 |
using namespace lpp::rostest; |
||
10 |
|||
11 |
4 |
TEST(roslog_vlog, glog_syntax_severity_v1) { |
|
12 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
13 |
2 |
FLAGS_v = 3; |
|
14 |
|||
15 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG(1) << "Test" << 123); |
16 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
17 |
} |
||
18 |
|||
19 |
4 |
TEST(roslog_vlog, glog_syntax_severity_v3) { |
|
20 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
21 |
2 |
FLAGS_v = 3; |
|
22 |
|||
23 |
✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG(3) << "Test123"); |
24 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
25 |
} |
||
26 |
|||
27 |
4 |
TEST(roslog_vlog, glog_syntax_severity_v5) { |
|
28 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
29 |
2 |
FLAGS_v = 3; |
|
30 |
|||
31 |
✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG(5) << "Test123"); |
32 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
33 |
} |
||
34 |
|||
35 |
4 |
TEST(roslog_vlog, glog_syntax_severity_if_v1) { |
|
36 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
37 |
2 |
FLAGS_v = 3; |
|
38 |
|||
39 |
✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(1, true) << "Test123"); |
40 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
41 |
} |
||
42 |
|||
43 |
4 |
TEST(roslog_vlog, glog_syntax_severity_if_v3) { |
|
44 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
45 |
2 |
FLAGS_v = 3; |
|
46 |
|||
47 |
✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(1, true) << "Test123"); |
48 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
49 |
} |
||
50 |
|||
51 |
4 |
TEST(roslog_vlog, glog_syntax_severity_if_v5) { |
|
52 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
53 |
2 |
FLAGS_v = 3; |
|
54 |
|||
55 |
✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(5, true) << "Test123"); |
56 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
57 |
} |
||
58 |
|||
59 |
4 |
TEST(roslog_vlog, glog_syntax_severity_ifnot_v1) { |
|
60 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
61 |
2 |
FLAGS_v = 3; |
|
62 |
|||
63 |
✓✗ | 3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(1, false) << "Test123"); |
64 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
65 |
} |
||
66 |
|||
67 |
4 |
TEST(roslog_vlog, glog_syntax_severity_ifnot_v3) { |
|
68 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
69 |
2 |
FLAGS_v = 3; |
|
70 |
|||
71 |
✓✗ | 3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(3, false) << "Test123"); |
72 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
73 |
} |
||
74 |
|||
75 |
4 |
TEST(roslog_vlog, glog_syntax_severity_ifnot_v5) { |
|
76 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
77 |
2 |
FLAGS_v = 3; |
|
78 |
|||
79 |
✓✗ | 3 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_IF(5, false) << "Test123"); |
80 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
81 |
} |
||
82 |
|||
83 |
4 |
TEST(roslog_vlog, glog_syntax_every_n_severity_v1) { |
|
84 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
85 |
2 |
FLAGS_v = 3; |
|
86 |
|||
87 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
88 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_EVERY_N(1, 3) << "Test" << 123); |
89 |
|||
90 |
✓✓ | 10 |
if (i % 3 == 0) { |
91 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
92 |
} else { |
||
93 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
94 |
} |
||
95 |
} |
||
96 |
} |
||
97 |
|||
98 |
4 |
TEST(roslog_vlog, glog_syntax_every_n_severity_v3) { |
|
99 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
100 |
2 |
FLAGS_v = 3; |
|
101 |
|||
102 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
103 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_EVERY_N(3, 3) << "Test" << 123); |
104 |
|||
105 |
✓✓ | 10 |
if (i % 3 == 0) { |
106 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
107 |
} else { |
||
108 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
109 |
} |
||
110 |
} |
||
111 |
} |
||
112 |
|||
113 |
4 |
TEST(roslog_vlog, glog_syntax_every_n_severity_v5) { |
|
114 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
115 |
2 |
FLAGS_v = 3; |
|
116 |
|||
117 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
118 |
✓✓✗✗ ✗✗✗✗ ✗✗✗✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(VLOG_EVERY_N(5, 3) << "Test" << 123); |
119 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
10 |
ASSERT_EQ(output, ""); |
120 |
} |
||
121 |
} |
||
122 |
|||
123 |
4 |
TEST(roslog_vlog, glog_syntax_if_every_n_severity_v1) { |
|
124 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
125 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
126 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
VLOG_IF_EVERY_N(1, i <= 3, 3) << "Test" << 123; |
127 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
128 |
|||
129 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
130 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
131 |
} else { |
||
132 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
133 |
} |
||
134 |
} |
||
135 |
} |
||
136 |
|||
137 |
4 |
TEST(roslog_vlog, glog_syntax_if_every_n_severity_v3) { |
|
138 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
139 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
140 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
VLOG_IF_EVERY_N(3, i <= 3, 3) << "Test" << 123; |
141 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
142 |
|||
143 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
144 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
145 |
} else { |
||
146 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
147 |
} |
||
148 |
} |
||
149 |
} |
||
150 |
|||
151 |
2 |
TEST(roslog_vlog, glog_syntax_if_every_n_severity_v5) { |
|
152 |
1 |
LOG_INIT(*test_argv); |
|
153 |
1 |
FLAGS_v = 3; |
|
154 |
|||
155 |
6 |
for (int i = 0; i < 5; i++) { |
|
156 |
5 |
testing::internal::CaptureStdout(); |
|
157 |
5 |
VLOG_IF_EVERY_N(5, i <= 3, 3) << "Test" << 123; |
|
158 |
5 |
std::string output = testing::internal::GetCapturedStdout(); |
|
159 |
|||
160 |
5 |
ASSERT_EQ(output, ""); |
|
161 |
} |
||
162 |
} |
||
163 |
Generated by: GCOVR (Version 4.2) |