GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/lpp/custom/test_lpp_custom_rosprintf.cc Lines: 36 36 100.0 %
Date: 2025-03-04 18:34:12 Branches: 58 146 39.7 %

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
using namespace lpp::testing;
12
13
4
TEST(lpp_rosprintf, ros_info) {
14

2
  LOG_INIT(*test_argv, logCallback);
15
16
2
  testing::internal::CaptureStdout();
17

2
  ROS_INFO(ERROR_MESSAGE, 3.3, 5.5);
18
2
  std::string c = testing::internal::GetCapturedStdout();
19
20



4
  ASSERT_EQ(c, info + EXPECTED_ERROR_MESSAGE);
21
}
22
23
4
TEST(lpp_rosprintf, ros_info_once) {
24

2
  LOG_INIT(*test_argv, logCallback);
25
26
2
  testing::internal::CaptureStdout();
27



2
  ROS_INFO_ONCE(ERROR_MESSAGE, 3.3, 5.5);
28
2
  std::string c = testing::internal::GetCapturedStdout();
29
30



4
  ASSERT_EQ(c, info + EXPECTED_ERROR_MESSAGE);
31
}
32
33
4
TEST(lpp_rosprintf, ros_warn) {
34

2
  LOG_INIT(*test_argv, logCallback);
35
36
2
  testing::internal::CaptureStdout();
37

2
  ROS_WARN(ERROR_MESSAGE, 3.3, 5.5);
38
2
  std::string c = testing::internal::GetCapturedStdout();
39
40



4
  ASSERT_EQ(c, warning + EXPECTED_ERROR_MESSAGE);
41
}
42
43
4
TEST(lpp_rosprintf, ros_warn_once) {
44

2
  LOG_INIT(*test_argv, logCallback);
45
46
2
  testing::internal::CaptureStdout();
47



2
  ROS_WARN_ONCE(ERROR_MESSAGE, 3.3, 5.5);
48
2
  std::string c = testing::internal::GetCapturedStdout();
49
50



4
  ASSERT_EQ(c, warning + EXPECTED_ERROR_MESSAGE);
51
}
52
53
4
TEST(lpp_rosprintf, ros_error) {
54

2
  LOG_INIT(*test_argv, logCallback);
55
56
2
  testing::internal::CaptureStdout();
57

2
  ROS_ERROR(ERROR_MESSAGE, 3.3, 5.5);
58
2
  std::string c = testing::internal::GetCapturedStdout();
59
60



4
  ASSERT_EQ(c, error + EXPECTED_ERROR_MESSAGE);
61
}
62
63
2
TEST(lpp_rosprintf, ros_error_once) {
64
1
  LOG_INIT(*test_argv, logCallback);
65
66
1
  testing::internal::CaptureStdout();
67
1
  ROS_ERROR_ONCE(ERROR_MESSAGE, 3.3, 5.5);
68
1
  std::string c = testing::internal::GetCapturedStdout();
69
70
2
  ASSERT_EQ(c, error  + EXPECTED_ERROR_MESSAGE);
71
}