GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/glog/test_glog_rosprintf.cc Lines: 48 56 85.7 %
Date: 2025-03-04 18:34:12 Branches: 88 384 22.9 %

Line Branch Exec Source
1
//
2
// Created by 4c3y (acey) on 08.09.22.
3
//
4
5
#include <gtest/gtest.h>
6
#include <test_utils.h>
7
#include <log++.h>
8
9
4
TEST(glog_rosprintf, ros_debug) {
10
2
  LOG_INIT(*test_argv);
11
12


3
  std::string c = LPP_CAPTURE_STDERR(ROS_DEBUG("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
13
14



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
15



2
  ASSERT_TRUE(c[0] == 'I');
16
}
17
18
4
TEST(glog_rosprintf, ros_debug_once) {
19
2
  LOG_INIT(*test_argv);
20
21


3
  std::string c = LPP_CAPTURE_STDERR(ROS_DEBUG_ONCE("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
22
23



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
24



2
  ASSERT_TRUE(c[0] == 'I');
25
}
26
27
4
TEST(glog_rosprintf, ros_info) {
28
2
  LOG_INIT(*test_argv);
29
30


3
  std::string c = LPP_CAPTURE_STDERR(ROS_INFO("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
31
32



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
33



2
  ASSERT_TRUE(c[0] == 'I');
34
}
35
36
4
TEST(glog_rosprintf, ros_info_once) {
37
2
  LOG_INIT(*test_argv);
38
39


3
  std::string c = LPP_CAPTURE_STDERR(ROS_INFO_ONCE("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
40
41



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
42



2
  ASSERT_TRUE(c[0] == 'I');
43
}
44
45
4
TEST(glog_rosprintf, ros_warn) {
46
2
  LOG_INIT(*test_argv);
47
48


3
  std::string c = LPP_CAPTURE_STDERR(ROS_WARN("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
49
50



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
51



2
  ASSERT_TRUE(c[0] == 'W');
52
}
53
54
4
TEST(glog_rosprintf, ros_warn_once) {
55
2
  LOG_INIT(*test_argv);
56
57


3
  std::string c = LPP_CAPTURE_STDERR(ROS_WARN_ONCE("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
58
59



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
60



2
  ASSERT_TRUE(c[0] == 'W');
61
}
62
63
4
TEST(glog_rosprintf, ros_error) {
64
2
  LOG_INIT(*test_argv);
65
66


3
  std::string c = LPP_CAPTURE_STDERR(ROS_ERROR("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
67
68



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
69



2
  ASSERT_TRUE(c[0] == 'E');
70
}
71
72
4
TEST(glog_rosprintf, ros_error_once) {
73
2
  LOG_INIT(*test_argv);
74
75


3
  std::string c = LPP_CAPTURE_STDERR(ROS_ERROR_ONCE("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
76
77



2
  ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
78



2
  ASSERT_TRUE(c[0] == 'E');
79
}
80
81
4
TEST(glog_rosprintf, ros_fatal) {
82
2
  LOG_INIT(*test_argv);
83
84
  std::function<void()> fn = []() {
85
    std::string c = LPP_CAPTURE_STDERR(ROS_FATAL("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
86
87
    ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
88
    ASSERT_TRUE(c[0] == 'E');
89
2
  };
90
91



2
  ASSERT_TRUE(checkAbort(fn));
92
}
93
94
2
TEST(glog_rosprintf, ros_fatal_once) {
95
1
  LOG_INIT(*test_argv);
96
97
  std::function<void()> fn = []() {
98
    std::string c = LPP_CAPTURE_STDERR(ROS_FATAL_ONCE("Base angle (%f) is less than the minimum angle (%f)", 3.3, 5.5));
99
100
    ASSERT_TRUE(isSubstring(c, "Base angle (3.300000) is less than the minimum angle (5.500000)\n"));
101
    ASSERT_TRUE(c[0] == 'E');
102
1
  };
103
104
1
  ASSERT_TRUE(checkAbort(fn));
105
}