GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by 4c3y (acey) on 15.12.22. |
||
3 |
// |
||
4 |
|||
5 |
#include <gtest/gtest.h> |
||
6 |
#include <test_utils.h> |
||
7 |
#include <log++.h> |
||
8 |
|||
9 |
using namespace lpp::rostest; |
||
10 |
|||
11 |
4 |
TEST(roslog_if_every_n, glog_syntax_if_every_n_severity_debug) { |
|
12 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
13 |
|||
14 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
15 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
16 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
DLOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
17 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
18 |
|||
19 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
20 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(debug, removeNumbersFromString(output)); |
21 |
} else { |
||
22 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
23 |
} |
||
24 |
} |
||
25 |
} |
||
26 |
|||
27 |
4 |
TEST(roslog_if_every_n, glog_syntax_if_every_n_severity_info) { |
|
28 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
29 |
|||
30 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
31 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
32 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
33 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
34 |
|||
35 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
36 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(info, removeNumbersFromString(output)); |
37 |
} else { |
||
38 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
39 |
} |
||
40 |
} |
||
41 |
} |
||
42 |
|||
43 |
4 |
TEST(roslog_if_every_n, glog_syntax_if_every_n_severity_warning) { |
|
44 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
45 |
|||
46 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
47 |
✓✗ | 10 |
testing::internal::CaptureStderr(); |
48 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(WARNING, i <= 3, 3) << "Test" << 123; |
49 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
50 |
|||
51 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
52 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(warning, removeNumbersFromString(output)); |
53 |
} else { |
||
54 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
55 |
} |
||
56 |
} |
||
57 |
|||
58 |
} |
||
59 |
|||
60 |
4 |
TEST(roslog_if_every_n, glog_syntax_if_every_n_severity_error) { |
|
61 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
62 |
|||
63 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
64 |
✓✗ | 10 |
testing::internal::CaptureStderr(); |
65 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(ERROR, i <= 3, 3) << "Test" << 123; |
66 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
67 |
|||
68 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
69 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗ |
12 |
ASSERT_EQ(error, removeNumbersFromString(output)); |
70 |
} else { |
||
71 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
72 |
} |
||
73 |
} |
||
74 |
} |
||
75 |
|||
76 |
2 |
TEST(roslog_if_every_n, glog_syntax_if_every_n_severity_fatal) { |
|
77 |
1 |
LOG_INIT(*test_argv); |
|
78 |
|||
79 |
6 |
for (int i = 0; i < 5; i++) { |
|
80 |
5 |
testing::internal::CaptureStderr(); |
|
81 |
5 |
LOG_IF_EVERY_N(FATAL, i <= 3, 3) << "Test" << 123; |
|
82 |
5 |
std::string output = testing::internal::GetCapturedStderr(); |
|
83 |
|||
84 |
5 |
if (i <= 3 && i % 3 == 0) { |
|
85 |
6 |
ASSERT_EQ(fatal, removeNumbersFromString(output)); |
|
86 |
} else { |
||
87 |
3 |
ASSERT_EQ(output, ""); |
|
88 |
} |
||
89 |
} |
||
90 |
} |
Generated by: GCOVR (Version 4.2) |