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 <log++.h> |
||
7 |
#include <test_utils.h> |
||
8 |
|||
9 |
4 |
TEST(default_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::CaptureStderr(); |
14 |
✓✓✓✓ ✓✓✓✗ ✓✗✓✗ ✓✗ |
10 |
DLOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
15 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
16 |
|||
17 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
18 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
19 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, LPP_FILENAME)); |
20 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
8 |
ASSERT_EQ(output[0], 'I'); |
21 |
} else { |
||
22 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
23 |
} |
||
24 |
} |
||
25 |
} |
||
26 |
|||
27 |
4 |
TEST(default_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::CaptureStderr(); |
32 |
✓✓✓✓ ✓✓✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(INFO, i <= 3, 3) << "Test" << 123; |
33 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
34 |
|||
35 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
36 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
37 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, LPP_FILENAME)); |
38 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
8 |
ASSERT_EQ(output[0], 'I'); |
39 |
} else { |
||
40 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
41 |
} |
||
42 |
} |
||
43 |
} |
||
44 |
|||
45 |
4 |
TEST(default_if_every_n, glog_syntax_if_every_n_severity_warning) { |
|
46 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
47 |
|||
48 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
49 |
✓✗ | 10 |
testing::internal::CaptureStderr(); |
50 |
✓✓✓✓ ✓✓✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(WARNING, i <= 3, 3) << "Test" << 123; |
51 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
52 |
|||
53 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
54 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
55 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, LPP_FILENAME)); |
56 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
8 |
ASSERT_EQ(output[0], 'W'); |
57 |
} else { |
||
58 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
59 |
} |
||
60 |
} |
||
61 |
} |
||
62 |
|||
63 |
4 |
TEST(default_if_every_n, glog_syntax_if_every_n_severity_error) { |
|
64 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
65 |
2 |
FLAGS_v = 3; |
|
66 |
|||
67 |
✓✓ | 12 |
for (int i = 0; i < 5; i++) { |
68 |
✓✗ | 10 |
testing::internal::CaptureStderr(); |
69 |
✓✓✓✓ ✓✓✓✗ ✓✗✓✗ ✓✗ |
10 |
LOG_IF_EVERY_N(ERROR, i <= 3, 3) << "Test" << 123; |
70 |
✓✗ | 10 |
std::string output = testing::internal::GetCapturedStderr(); |
71 |
|||
72 |
✓✓✓✓ |
10 |
if (i <= 3 && i % 3 == 0) { |
73 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, "Test123")); |
74 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ |
4 |
ASSERT_TRUE(isSubstring(output, LPP_FILENAME)); |
75 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
8 |
ASSERT_EQ(output[0], 'E'); |
76 |
} else { |
||
77 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
6 |
ASSERT_EQ(output, ""); |
78 |
} |
||
79 |
} |
||
80 |
} |
||
81 |
|||
82 |
2 |
TEST(default_if_every_n, glog_syntax_if_every_n_severity_fatal) { |
|
83 |
1 |
LOG_INIT(*test_argv); |
|
84 |
1 |
FLAGS_v = 3; |
|
85 |
|||
86 |
std::function<void()> fn = []() { |
||
87 |
for (int i = 0; i < 5; i++) { |
||
88 |
testing::internal::CaptureStderr(); |
||
89 |
LOG_IF_EVERY_N(FATAL, i <= 3, 3) << "Test" << 123; |
||
90 |
std::string output = testing::internal::GetCapturedStderr(); |
||
91 |
} |
||
92 |
1 |
}; |
|
93 |
|||
94 |
1 |
ASSERT_TRUE(checkAbort(fn)); |
|
95 |
} |
Generated by: GCOVR (Version 4.2) |