GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/lpp/custom/test_lpp_custom_basic.cc Lines: 80 80 100.0 %
Date: 2025-03-04 18:34:12 Branches: 145 404 35.9 %

Line Branch Exec Source
1
//
2
// Created by 4c3y (acey) on 24.11.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
//! LPP syntax
13
14
4
TEST(lpp_custom_basic, lpp_syntax_severity_debug) {
15

2
  LOG_INIT(*test_argv, logCallback);
16
17

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(D, "test" << 123));
18
19



4
  ASSERT_EQ(output, debug + test123);
20
}
21
22
4
TEST(lpp_custom_basic, lpp_syntax_severity_info) {
23

2
  LOG_INIT(*test_argv, logCallback);
24
25

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(I, "test" << 123));
26
27



4
  ASSERT_EQ(output, info + test123);
28
}
29
30
4
TEST(lpp_custom_basic, lpp_syntax_severity_warning) {
31

2
  LOG_INIT(*test_argv, logCallback);
32
33

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(W, "test" << 123));
34
35



4
  ASSERT_EQ(output, warning + test123);
36
}
37
38
4
TEST(lpp_custom_basic, lpp_syntax_severity_error) {
39

2
  LOG_INIT(*test_argv, logCallback);
40
41

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(E, "test" << 123));
42
43



4
  ASSERT_EQ(output, error + test123);
44
}
45
46
4
TEST(lpp_custom_basic, lpp_syntax_severity_fatal) {
47

2
  LOG_INIT(*test_argv, logCallback);
48
49

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(F, "test" << 123));
50
51



4
  ASSERT_EQ(output, fatal + test123);
52
}
53
54
55
//! Glog syntax
56
4
TEST(lpp_custom_basic, glog_syntax_severity_debug) {
57

2
  LOG_INIT(*test_argv, logCallback);
58
59

3
  std::string output = LPP_CAPTURE_STDOUT(DLOG(INFO) << "test" << 123;);
60
61



4
  ASSERT_EQ(output, debug + test123);
62
}
63
64
4
TEST(lpp_custom_basic, glog_syntax_severity_info) {
65

2
  LOG_INIT(*test_argv, logCallback);
66
67

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(INFO) << "test" << 123;);
68
69



4
  ASSERT_EQ(output, info + test123);
70
}
71
72
4
TEST(lpp_custom_basic, glog_syntax_severity_warning) {
73

2
  LOG_INIT(*test_argv, logCallback);
74
75

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(WARNING) << "test" << 123;);
76
77



4
  ASSERT_EQ(output, warning + test123);
78
}
79
80
4
TEST(lpp_custom_basic, glog_syntax_severity_error) {
81

2
  LOG_INIT(*test_argv, logCallback);
82
83

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(ERROR) << "test" << 123;);
84
85



4
  ASSERT_EQ(output, error + test123);
86
}
87
88
4
TEST(lpp_custom_basic, glog_syntax_severity_fatal) {
89

2
  LOG_INIT(*test_argv, logCallback);
90
91

3
  std::string output = LPP_CAPTURE_STDOUT(LOG(FATAL) << "test" << 123;);
92
93



4
  ASSERT_EQ(output, fatal + test123);
94
}
95
96
97
//! Roslog syntax
98
4
TEST(lpp_custom_basic, roslog_syntax_severity_debug) {
99
2
  LOG_INIT(*test_argv);
100
101

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_DEBUG("test123"));
102



4
  ASSERT_EQ(output, debug + test123);
103
}
104
105
4
TEST(lpp_custom_basic, roslog_syntax_severity_debug_stream) {
106
2
  LOG_INIT(*test_argv);
107
108

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_DEBUG_STREAM("test" << 123));
109



4
  ASSERT_EQ(output, debug + test123);
110
}
111
112
4
TEST(lpp_custom_basic, roslog_syntax_severity_info) {
113
2
  LOG_INIT(*test_argv);
114
115

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_INFO("test123"));
116



4
  ASSERT_EQ(output, info + test123);
117
}
118
119
4
TEST(lpp_custom_basic, roslog_syntax_severity_info_stream) {
120
2
  LOG_INIT(*test_argv);
121
122

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_INFO_STREAM("test" << 123));
123



4
  ASSERT_EQ(output, info + test123);
124
}
125
126
4
TEST(lpp_custom_basic, roslog_syntax_severity_warning) {
127
2
  LOG_INIT(*test_argv);
128
129

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_WARN("test123"));
130



4
  ASSERT_EQ(output, warning + test123);
131
}
132
133
4
TEST(lpp_custom_basic, roslog_syntax_severity_warning_stream) {
134
2
  LOG_INIT(*test_argv);
135
136

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_WARN_STREAM("test" << 123));
137



4
  ASSERT_EQ(output, warning + test123);
138
}
139
140
4
TEST(lpp_custom_basic, roslog_syntax_severity_error) {
141
2
  LOG_INIT(*test_argv);
142
143

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_ERROR("test123"));
144



4
  ASSERT_EQ(output, error + test123);
145
}
146
147
4
TEST(lpp_custom_basic, roslog_syntax_severity_error_stream) {
148
2
  LOG_INIT(*test_argv);
149
150

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_ERROR_STREAM("test" << 123));
151



4
  ASSERT_EQ(output, error + test123);
152
}
153
154
4
TEST(lpp_custom_basic, roslog_syntax_severity_fatal) {
155
2
  LOG_INIT(*test_argv);
156
157

3
  std::string output = LPP_CAPTURE_STDOUT(ROS_FATAL("test123"));
158



4
  ASSERT_EQ(output, fatal + test123);
159
}
160
161
2
TEST(lpp_custom_basic, roslog_syntax_severity_fatal_stream) {
162
1
  LOG_INIT(*test_argv);
163
164

2
  std::string output = LPP_CAPTURE_STDOUT(ROS_FATAL_STREAM("test" << 123));
165
2
  ASSERT_EQ(output, fatal + test123);
166
}
167