GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Created by 4c3y (acey) on 28.09.22. |
||
3 |
// |
||
4 |
|||
5 |
#include <gtest/gtest.h> |
||
6 |
#include <log++.h> |
||
7 |
#include <test_utils.h> |
||
8 |
|||
9 |
4 |
TEST(default_log_string, severity_info) { |
|
10 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
11 |
|||
12 |
2 |
std::vector<std::string> errors; |
|
13 |
|||
14 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
15 |
✓✗ | 2 |
testing::internal::CaptureStderr(); |
16 |
✓✗✓✗ ✓✗✓✗ |
2 |
LOG_STRING(INFO, &errors) << "LOG_STRING: " << "collected info"; |
17 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStderr(); |
18 |
|||
19 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
20 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected info", errors.at(0)); |
21 |
} |
||
22 |
|||
23 |
4 |
TEST(default_log_string, severity_info_null) { |
|
24 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
25 |
|||
26 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG_STRING(INFO, nullptr) << "LOG_STRING: " << "collected info"); |
27 |
|||
28 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'I'); |
29 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_default_log_string.cc")); |
30 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "LOG_STRING: collected info")); |
31 |
} |
||
32 |
|||
33 |
4 |
TEST(default_log_string, severity_warning) { |
|
34 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
35 |
|||
36 |
2 |
std::vector<std::string> errors; |
|
37 |
|||
38 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
39 |
✓✗ | 2 |
testing::internal::CaptureStderr(); |
40 |
✓✗✓✗ ✓✗✓✗ |
2 |
LOG_STRING(WARNING, &errors) << "LOG_STRING: " << "collected warn"; |
41 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStderr(); |
42 |
|||
43 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
44 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected warn", errors.at(0)); |
45 |
} |
||
46 |
|||
47 |
4 |
TEST(default_log_string, severity_warning_null) { |
|
48 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
49 |
|||
50 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG_STRING(WARNING, nullptr) << "LOG_STRING: " << "collected warn"); |
51 |
|||
52 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'W'); |
53 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_default_log_string.cc")); |
54 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "LOG_STRING: collected warn")); |
55 |
} |
||
56 |
|||
57 |
4 |
TEST(default_log_string, severity_error) { |
|
58 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
59 |
|||
60 |
2 |
std::vector<std::string> errors; |
|
61 |
|||
62 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
63 |
✓✗ | 2 |
testing::internal::CaptureStderr(); |
64 |
✓✗✓✗ ✓✗✓✗ |
2 |
LOG_STRING(ERROR, &errors) << "LOG_STRING: " << "collected error"; |
65 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStderr(); |
66 |
|||
67 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
68 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected error", errors.at(0)); |
69 |
} |
||
70 |
|||
71 |
4 |
TEST(default_log_string, severity_error_null) { |
|
72 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
73 |
|||
74 |
✓✗✓✗ ✓✗✓✗ |
3 |
std::string output = LPP_CAPTURE_STDERR(LOG_STRING(ERROR, nullptr) << "LOG_STRING: " << "collected error"); |
75 |
|||
76 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ(output[0], 'E'); |
77 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "test_default_log_string.cc")); |
78 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_TRUE(isSubstring(output, "LOG_STRING: collected error")); |
79 |
} |
||
80 |
|||
81 |
4 |
TEST(default_log_string, severity_fatal) { |
|
82 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
83 |
|||
84 |
2 |
std::vector<std::string> errors; |
|
85 |
|||
86 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
87 |
✓✗ | 2 |
testing::internal::CaptureStderr(); |
88 |
✓✗✓✗ ✓✗✓✗ |
2 |
LOG_STRING(FATAL, &errors) << "LOG_STRING: " << "collected fatal"; |
89 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStderr(); |
90 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
91 |
|||
92 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected fatal", errors.at(0)); |
93 |
} |
||
94 |
|||
95 |
2 |
TEST(default_log_string, severity_fatal_null) { |
|
96 |
1 |
LOG_INIT(*test_argv); |
|
97 |
std::function<void()> fn = []() { |
||
98 |
LPP_CAPTURE_STDERR(LOG_STRING(FATAL, nullptr) << "LOG_STRING: " << "collected fatal"); |
||
99 |
1 |
}; |
|
100 |
|||
101 |
1 |
ASSERT_TRUE(checkAbort(fn)); |
|
102 |
} |
Generated by: GCOVR (Version 4.2) |