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