GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/lpp/test_lpp_timed.cc Lines: 69 69 100.0 %
Date: 2025-03-04 18:34:12 Branches: 268 690 38.8 %

Line Branch Exec Source
1
//
2
// Created by 4c3y (acey) on 16.09.22.
3
//
4
5
#include <gtest/gtest.h>
6
#include <log++.h>
7
#include <mutex>
8
#include <async_tests.h>
9
10
1
std::vector<AsyncTest> generateTests() {
11
  return {
12



30
  {"lpp_timed_lpp_syntax_severity_debug_Test","DEBUG Test123\n",[]() { LOG_TIMED(D, 1, "Test" << 123); }, EQUAL, STDOUT},
13



30
  {"lpp_timed_lpp_syntax_severity_info_Test","INFO  Test123\n",[]() { LOG_TIMED(I, 1, "Test" << 123); }, EQUAL, STDOUT},
14



30
  {"lpp_timed_lpp_syntax_severity_warning_Test","WARN  Test123\n",[]() { LOG_TIMED(W, 1, "Test" << 123); }, EQUAL, STDOUT},
15



30
  {"lpp_timed_lpp_syntax_severity_error_Test","ERROR Test123\n",[]() { LOG_TIMED(E, 1, "Test" << 123); }, EQUAL, STDOUT},
16



30
  {"lpp_timed_lpp_syntax_severity_fatal_Test","FATAL Test123\n",[]() { LOG_TIMED(F, 1, "Test" << 123); }, EQUAL, STDOUT},
17
18


30
  {"lpp_timed_glog_syntax_severity_debug_Test","DEBUG Test123\n",[]() { DLOG_EVERY_T(INFO, 1) << "Test" << 123; }, EQUAL, STDOUT},
19


30
  {"lpp_timed_glog_syntax_severity_info_Test","INFO  Test123\n",[]() { LOG_EVERY_T(INFO, 1) << "Test" << 123; }, EQUAL, STDOUT},
20


30
  {"lpp_timed_glog_syntax_severity_warning_Test","WARN  Test123\n",[]() { LOG_EVERY_T(WARNING, 1) << "Test" << 123; }, EQUAL, STDOUT},
21


30
  {"lpp_timed_glog_syntax_severity_error_Test","ERROR Test123\n",[]() { LOG_EVERY_T(ERROR, 1) << "Test" << 123; }, EQUAL, STDOUT},
22


30
  {"lpp_timed_glog_syntax_severity_fatal_Test","FATAL Test123\n",[]() { LOG_EVERY_T(FATAL, 1) << "Test" << 123; }, EQUAL, STDOUT},
23
24



30
  {"lpp_timed_ros_syntax_severity_debug_Test", "DEBUG Test123\n", []() {ROS_DEBUG_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
25



30
  {"lpp_timed_ros_syntax_severity_debug_stream_Test", "DEBUG Test123\n", []() {ROS_DEBUG_STREAM_THROTTLE(1, "Test" << 123); }, EQUAL, STDOUT},
26



30
  {"lpp_timed_ros_syntax_severity_info_Test", "INFO  Test123\n", []() {ROS_INFO_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
27



30
  {"lpp_timed_ros_syntax_severity_info_stream_Test", "INFO  Test123\n", []() {ROS_INFO_STREAM_THROTTLE(1, "Test" << 123); }, EQUAL, STDOUT},
28



30
  {"lpp_timed_ros_syntax_severity_warning_Test", "WARN  Test123\n", []() {ROS_WARN_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
29



30
  {"lpp_timed_ros_syntax_severity_warning_stream_Test", "WARN  Test123\n", []() {ROS_WARN_STREAM_THROTTLE(1, "Test" << 123); }, EQUAL, STDOUT},
30



30
  {"lpp_timed_ros_syntax_severity_error_Test", "ERROR Test123\n", []() {ROS_ERROR_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
31



30
  {"lpp_timed_ros_syntax_severity_error_stream_Test", "ERROR Test123\n", []() {ROS_ERROR_STREAM_THROTTLE(1, "Test" << 123); }, EQUAL, STDOUT},
32



30
  {"lpp_timed_ros_syntax_severity_fatal_Test", "FATAL Test123\n", []() {ROS_FATAL_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
33


30
  {"lpp_timed_ros_syntax_severity_fatal_stream_Test", "FATAL Test123\n", []() {ROS_FATAL_STREAM_THROTTLE(1, "Test123"); }, EQUAL, STDOUT},
34































21
  };
35
}
36
37
4
TEST(lpp_timed, lpp_syntax_floating_point_time) {
38
2
  LOG_INIT(*test_argv);
39
12
  for (int i = 0; i < 5; i++) {
40



15
    std::string output = LPP_CAPTURE_STDOUT(LOG_TIMED(I, 0.1, "Test" << 123));
41
10
    if (i % 2 == 0) {
42


6
      ASSERT_EQ(output, "INFO  Test123\n");
43
    }
44
    //sleep 0.1s
45
10
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
46
  }
47
}
48
49
4
TEST(lpp_timed, lpp_syntax_severity_debug) {
50




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
51
}
52
53
4
TEST(lpp_timed, lpp_syntax_severity_info) {
54




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
55
}
56
57
4
TEST(lpp_timed, lpp_syntax_severity_warning) {
58




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
59
}
60
61
4
TEST(lpp_timed, lpp_syntax_severity_error) {
62




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
63
}
64
65
4
TEST(lpp_timed, lpp_syntax_severity_fatal) {
66




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
67
}
68
69
4
TEST(lpp_timed, glog_syntax_severity_debug) {
70




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
71
}
72
73
4
TEST(lpp_timed, glog_syntax_severity_info) {
74




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
75
}
76
77
4
TEST(lpp_timed, glog_syntax_severity_warning) {
78




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
79
}
80
81
4
TEST(lpp_timed, glog_syntax_severity_error) {
82




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
83
}
84
85
4
TEST(lpp_timed, glog_syntax_severity_fatal) {
86




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
87
}
88
89
4
TEST(lpp_timed, ros_syntax_severity_debug) {
90




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
91
}
92
93
4
TEST(lpp_timed, ros_syntax_severity_debug_stream) {
94




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
95
}
96
97
4
TEST(lpp_timed, ros_syntax_severity_info) {
98




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
99
}
100
101
4
TEST(lpp_timed, ros_syntax_severity_info_stream) {
102




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
103
}
104
105
4
TEST(lpp_timed, ros_syntax_severity_warning) {
106




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
107
}
108
109
4
TEST(lpp_timed, ros_syntax_severity_warning_stream) {
110




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
111
}
112
113
4
TEST(lpp_timed, ros_syntax_severity_error) {
114




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
115
}
116
117
4
TEST(lpp_timed, ros_syntax_severity_error_stream) {
118




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
119
}
120
121
4
TEST(lpp_timed, ros_syntax_severity_fatal) {
122




2
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
123
}
124
125
2
TEST(lpp_timed, ros_syntax_severity_fatal_stream) {
126
1
  ASSERT_TRUE(TestResult::getInstance().get(GET_CLASS_NAME(*this, nullptr)));
127
}