GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by 4c3y (acey) on 12.09.22. |
||
3 |
// |
||
4 |
|||
5 |
#include <gtest/gtest.h> |
||
6 |
#include <test_utils.h> |
||
7 |
#include <log++.h> |
||
8 |
|||
9 |
4 |
TEST(default_LogFirstN, glog_syntax_severity_debug) { |
|
10 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
11 |
|||
12 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
13 |
✓✗ | 18 |
std::string output = LPP_CAPTURE_STDERR(DLOG_FIRST_N(INFO, 3) << "Test" << 123); |
14 |
|||
15 |
✓✓ | 10 |
if (i < 3) { |
16 |
|||
17 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
18 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "test_default_first_n.cc")); |
19 |
|||
20 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
6 |
ASSERT_EQ(output[0], 'I'); |
21 |
} else { |
||
22 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
23 |
} |
||
24 |
} |
||
25 |
} |
||
26 |
|||
27 |
4 |
TEST(default_LogFirstN, glog_syntax_severity_info) { |
|
28 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
29 |
|||
30 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
31 |
✓✓✓✓ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDERR(LOG_FIRST_N(INFO, 3) << "Test" << 123); |
32 |
|||
33 |
✓✓ | 10 |
if (i < 3) { |
34 |
|||
35 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
36 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "test_default_first_n.cc")); |
37 |
|||
38 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
6 |
ASSERT_EQ(output[0], 'I'); |
39 |
} else { |
||
40 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
41 |
} |
||
42 |
} |
||
43 |
} |
||
44 |
|||
45 |
4 |
TEST(default_LogFirstN, glog_syntax_severity_warning) { |
|
46 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
47 |
|||
48 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
49 |
✓✓✓✓ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDERR(LOG_FIRST_N(WARNING, 3) << "Test" << 123); |
50 |
|||
51 |
✓✓ | 10 |
if (i < 3) { |
52 |
|||
53 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
54 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "test_default_first_n.cc")); |
55 |
|||
56 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
6 |
ASSERT_EQ(output[0], 'W'); |
57 |
} else { |
||
58 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
59 |
} |
||
60 |
} |
||
61 |
} |
||
62 |
|||
63 |
4 |
TEST(default_LogFirstN, glog_syntax_severity_error) { |
|
64 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
65 |
|||
66 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
67 |
✓✓✓✓ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDERR(LOG_FIRST_N(ERROR, 3) << "Test" << 123); |
68 |
|||
69 |
✓✓ | 10 |
if (i < 3) { |
70 |
|||
71 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
72 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
6 |
ASSERT_TRUE(isSubstring(output, "test_default_first_n.cc")); |
73 |
|||
74 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
6 |
ASSERT_EQ(output[0], 'E'); |
75 |
} else { |
||
76 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
77 |
} |
||
78 |
} |
||
79 |
} |
||
80 |
|||
81 |
4 |
TEST(default_LogFirstN, glog_syntax_severity_fatal) { |
|
82 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
83 |
|||
84 |
std::function<void()> fn = []() { |
||
85 |
for (int i = 0; i < 5; i++) { |
||
86 |
std::string output = LPP_CAPTURE_STDERR(LOG_FIRST_N(ERROR, 3) << "Test" << 123); |
||
87 |
|||
88 |
if (i < 3) { |
||
89 |
|||
90 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
||
91 |
ASSERT_TRUE(isSubstring(output, "test_default_first_n.cc")); |
||
92 |
|||
93 |
ASSERT_EQ(output[0], 'E'); |
||
94 |
} else { |
||
95 |
ASSERT_EQ(output, ""); |
||
96 |
} |
||
97 |
} |
||
98 |
✓✗ | 4 |
}; |
99 |
|||
100 |
✓✗ | 2 |
checkAbort(fn); |
101 |
2 |
} |
|
102 |
|||
103 |
4 |
TEST(default_LogFirstN, lpp_syntax_severity_debug) { |
|
104 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
105 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(D, 3, "Test" << 123)); |
106 |
|||
107 |
✓✓ | 10 |
if (i < 3) { |
108 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "DEBUG Test123\n"); |
109 |
} else { |
||
110 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
111 |
} |
||
112 |
} |
||
113 |
} |
||
114 |
|||
115 |
4 |
TEST(default_LogFirstN, lpp_syntax_severity_info) { |
|
116 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
117 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(I, 3, "Test" << 123)); |
118 |
|||
119 |
✓✓ | 10 |
if (i < 3) { |
120 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "INFO Test123\n"); |
121 |
} else { |
||
122 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
123 |
} |
||
124 |
} |
||
125 |
} |
||
126 |
|||
127 |
4 |
TEST(default_LogFirstN, lpp_syntax_severity_warning) { |
|
128 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
129 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(W, 3, "Test" << 123)); |
130 |
|||
131 |
✓✓ | 10 |
if (i < 3) { |
132 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "WARN Test123\n"); |
133 |
} else { |
||
134 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
135 |
} |
||
136 |
} |
||
137 |
} |
||
138 |
|||
139 |
4 |
TEST(default_LogFirstN, lpp_syntax_severity_error) { |
|
140 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
141 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
15 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(E, 3, "Test" << 123)); |
142 |
|||
143 |
✓✓ | 10 |
if (i < 3) { |
144 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, "ERROR Test123\n"); |
145 |
} else { |
||
146 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
4 |
ASSERT_EQ(output, ""); |
147 |
} |
||
148 |
} |
||
149 |
} |
||
150 |
|||
151 |
2 |
TEST(default_LogFirstN, lpp_syntax_severity_fatal) { |
|
152 |
6 |
for (int i = 0; i < 5; i++) { |
|
153 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
10 |
std::string output = LPP_CAPTURE_STDOUT(LOG_FIRST(F, 3, "Test" << 123)); |
154 |
|||
155 |
5 |
if (i < 3) { |
|
156 |
3 |
ASSERT_EQ(output, "FATAL Test123\n"); |
|
157 |
} else { |
||
158 |
2 |
ASSERT_EQ(output, ""); |
|
159 |
} |
||
160 |
} |
||
161 |
} |
Generated by: GCOVR (Version 4.2) |