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(lpp_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::CaptureStdout(); |
16 |
✓✗✓✗ ✓✗ |
2 |
LOG_STRING(INFO, &errors) << "LOG_STRING: " << "collected info"; |
17 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStdout(); |
18 |
|||
19 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
20 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected info", errors.at(0)); |
21 |
} |
||
22 |
|||
23 |
4 |
TEST(lpp_log_string, severity_info_null) { |
|
24 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
25 |
|||
26 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(LOG_STRING(INFO, nullptr) << "LOG_STRING: " << "collected info"); |
27 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "INFO LOG_STRING: collected info\n"); |
28 |
} |
||
29 |
|||
30 |
4 |
TEST(lpp_log_string, severity_warning) { |
|
31 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
32 |
|||
33 |
2 |
std::vector<std::string> errors; |
|
34 |
|||
35 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
36 |
✓✗ | 2 |
testing::internal::CaptureStdout(); |
37 |
✓✗✓✗ ✓✗ |
2 |
LOG_STRING(WARNING, &errors) << "LOG_STRING: " << "collected warn"; |
38 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStdout(); |
39 |
|||
40 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
41 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected warn", errors.at(0)); |
42 |
} |
||
43 |
|||
44 |
4 |
TEST(lpp_log_string, severity_warning_null) { |
|
45 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
46 |
|||
47 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(LOG_STRING(WARNING, nullptr) << "LOG_STRING: " << "collected warn"); |
48 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "WARN LOG_STRING: collected warn\n"); |
49 |
} |
||
50 |
|||
51 |
4 |
TEST(lpp_log_string, severity_error) { |
|
52 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
53 |
|||
54 |
2 |
std::vector<std::string> errors; |
|
55 |
|||
56 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
57 |
✓✗ | 2 |
testing::internal::CaptureStdout(); |
58 |
✓✗✓✗ ✓✗ |
2 |
LOG_STRING(ERROR, &errors) << "LOG_STRING: " << "collected error"; |
59 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStdout(); |
60 |
|||
61 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
62 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected error", errors.at(0)); |
63 |
} |
||
64 |
|||
65 |
4 |
TEST(lpp_log_string, severity_error_null) { |
|
66 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
67 |
|||
68 |
✓✗✓✗ ✓✗ |
3 |
std::string output = LPP_CAPTURE_STDOUT(LOG_STRING(ERROR, nullptr) << "LOG_STRING: " << "collected error"); |
69 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, "ERROR LOG_STRING: collected error\n"); |
70 |
} |
||
71 |
|||
72 |
4 |
TEST(lpp_log_string, severity_fatal) { |
|
73 |
✓✗ | 2 |
LOG_INIT(*test_argv); |
74 |
|||
75 |
2 |
std::vector<std::string> errors; |
|
76 |
|||
77 |
//Can't capture variables in lambda with LPP_CAPTURE_STDERR() |
||
78 |
✓✗ | 2 |
testing::internal::CaptureStdout(); |
79 |
✓✗✓✗ ✓✗ |
2 |
LOG_STRING(FATAL, &errors) << "LOG_STRING: " << "collected fatal"; |
80 |
✓✗ | 2 |
std::string output = testing::internal::GetCapturedStdout(); |
81 |
✓✗✗✓ ✗✗✗✗ ✗✗ |
2 |
ASSERT_EQ(output, ""); |
82 |
|||
83 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ |
2 |
ASSERT_EQ("LOG_STRING: collected fatal", errors.at(0)); |
84 |
} |
||
85 |
|||
86 |
2 |
TEST(lpp_log_string, severity_fatal_null) { |
|
87 |
1 |
LOG_INIT(*test_argv); |
|
88 |
|||
89 |
✓✗✓✗ |
2 |
std::string output = LPP_CAPTURE_STDOUT(LOG_STRING(FATAL, nullptr) << "LOG_STRING: " << "collected error"); |
90 |
1 |
ASSERT_EQ(output, "FATAL LOG_STRING: collected error\n"); |
|
91 |
} |
Generated by: GCOVR (Version 4.2) |