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 |
4 |
TEST(lpp_if_every_n, glog_syntax_if_every_n_severity_debug) { |
|
10 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
11 |
|||
12 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
13 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
14 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
DLOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
15 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
16 |
|||
17 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
18 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(output, "DEBUG Test123\n"); |
19 |
} else { |
||
20 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
21 |
} |
||
22 |
} |
||
23 |
} |
||
24 |
|||
25 |
4 |
TEST(lpp_if_every_n, glog_syntax_if_every_n_severity_info) { |
|
26 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
27 |
|||
28 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
29 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
30 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
31 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
32 |
|||
33 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
34 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(output, "INFO Test123\n"); |
35 |
} else { |
||
36 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
37 |
} |
||
38 |
} |
||
39 |
} |
||
40 |
|||
41 |
4 |
TEST(lpp_if_every_n, glog_syntax_if_every_n_severity_warning) { |
|
42 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
43 |
|||
44 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
45 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
46 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(WARNING, i <= 3, 3) << "Test" << 123; |
47 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
48 |
|||
49 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
50 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(output, "WARN Test123\n"); |
51 |
} else { |
||
52 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
53 |
} |
||
54 |
} |
||
55 |
|||
56 |
} |
||
57 |
|||
58 |
4 |
TEST(lpp_if_every_n, glog_syntax_if_every_n_severity_error) { |
|
59 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
60 |
|||
61 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
62 |
✓✗ | 10 |
testing::internal::CaptureStdout(); |
63 |
✓✓✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(ERROR, i <= 3, 3) << "Test" << 123; |
64 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStdout(); |
65 |
|||
66 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
67 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
8 |
ASSERT_EQ(output, "ERROR Test123\n"); |
68 |
} else { |
||
69 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
70 |
} |
||
71 |
} |
||
72 |
} |
||
73 |
|||
74 |
2 |
TEST(lpp_if_every_n, glog_syntax_if_every_n_severity_fatal) { |
|
75 |
1 |
LOG_INIT(*test_argv); |
|
76 |
|||
77 |
6 |
for (int i = 0; i < 5; i++) { |
|
78 |
5 |
testing::internal::CaptureStdout(); |
|
79 |
5 |
LOG_IF_EVERY_N(FATAL, i <= 3, 3) << "Test" << 123; |
|
80 |
5 |
std::string output = testing::internal::GetCapturedStdout(); |
|
81 |
|||
82 |
5 |
if (i <= 3 && i % 3 == 0) { |
|
83 |
4 |
ASSERT_EQ(output, "FATAL Test123\n"); |
|
84 |
} else { |
||
85 |
3 |
ASSERT_EQ(output, ""); |
|
86 |
} |
||
87 |
} |
||
88 |
} |
Generated by: GCOVR (Version 4.2) |