11
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
- #include < gtest/gtest.h>
15
-
16
14
#include " service_log_checker.hpp"
17
- #include < rclcpp/node_options.hpp>
18
- #include < yaml-cpp/yaml.h>
15
+
19
16
#include < ament_index_cpp/get_package_share_directory.hpp>
17
+ #include < rclcpp/node_options.hpp>
20
18
#include < rclcpp_components/register_node_macro.hpp>
19
+
20
+ #include < gtest/gtest.h>
21
+ #include < yaml-cpp/yaml.h>
22
+
21
23
#include < memory>
22
24
#include < string>
23
25
using ServiceLog = tier4_system_msgs::msg::ServiceLog;
@@ -27,40 +29,38 @@ using namespace rclcpp;
27
29
28
30
TEST (ServiceCheckerTest, ServiceChecker)
29
31
{
30
-
31
- class PubManager : public rclcpp ::Node
32
+ class PubManager : public rclcpp ::Node
33
+ {
34
+ public:
35
+ PubManager () : Node(" test_pub_node" )
32
36
{
33
- public:
34
- PubManager () : Node(" test_pub_node" )
35
- {
36
- pub_odom_ = create_publisher<ServiceLog>(" service_log" , 1 );
37
- sub_odom_ = create_subscription<DiagnosticArray>(
38
- " /diagnostics" , 1 , std::bind (&PubManager::on_service_log, this , std::placeholders::_1));
39
- }
40
- rclcpp::Publisher<ServiceLog>::SharedPtr pub_odom_;
41
- rclcpp::Subscription<DiagnosticArray>::SharedPtr sub_odom_;
42
- bool flag = false ;
43
- void on_service_log (const DiagnosticArray::ConstSharedPtr msg)
44
- {
45
- if (msg->status .size () > 0 ) {
46
- auto diag_array = msg->status [0 ].message .c_str ();
47
- EXPECT_EQ (diag_array, " ERROR" );
48
- flag = true ;
49
- }
37
+ pub_odom_ = create_publisher<ServiceLog>(" service_log" , 1 );
38
+ sub_odom_ = create_subscription<DiagnosticArray>(
39
+ " /diagnostics" , 1 , std::bind (&PubManager::on_service_log, this , std::placeholders::_1));
40
+ }
41
+ rclcpp::Publisher<ServiceLog>::SharedPtr pub_odom_;
42
+ rclcpp::Subscription<DiagnosticArray>::SharedPtr sub_odom_;
43
+ bool flag = false ;
44
+ void on_service_log (const DiagnosticArray::ConstSharedPtr msg)
45
+ {
46
+ if (msg->status .size () > 0 ) {
47
+ auto diag_array = msg->status [0 ].message .c_str ();
48
+ EXPECT_EQ (diag_array, " ERROR" );
49
+ flag = true ;
50
50
}
51
- };
52
-
53
- rclcpp::init (0 , nullptr );
54
- auto node_options = rclcpp::NodeOptions{};
55
- auto test_target_node = std::make_shared<ServiceLogChecker>(node_options);
56
- auto test_log = std::make_shared<PubManager>();
57
- ServiceLog log ;
58
- log .type = 6 ;
59
- log .name = " test" ;
60
- log .node = " test_node" ;
61
- test_log->pub_odom_ ->publish (log );
62
-
63
- while (!test_log->flag ) {
64
51
}
52
+ };
53
+
54
+ rclcpp::init (0 , nullptr );
55
+ auto node_options = rclcpp::NodeOptions{};
56
+ auto test_target_node = std::make_shared<ServiceLogChecker>(node_options);
57
+ auto test_log = std::make_shared<PubManager>();
58
+ ServiceLog log ;
59
+ log .type = 6 ;
60
+ log .name = " test" ;
61
+ log .node = " test_node" ;
62
+ test_log->pub_odom_ ->publish (log );
65
63
64
+ while (!test_log->flag ) {
65
+ }
66
66
}
0 commit comments