From 7ea4bc3713595810cc3bd6f8b43e012d1a53b3e0 Mon Sep 17 00:00:00 2001 From: Mario-DL Date: Wed, 29 May 2024 08:59:12 +0000 Subject: [PATCH] Add test creating two content filter topics with the same topic name Signed-off-by: Mario-DL --- .../test_subscription_content_filter.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rclcpp/test/rclcpp/test_subscription_content_filter.cpp b/rclcpp/test/rclcpp/test_subscription_content_filter.cpp index 942aa1274e..372af03611 100644 --- a/rclcpp/test/rclcpp/test_subscription_content_filter.cpp +++ b/rclcpp/test/rclcpp/test_subscription_content_filter.cpp @@ -310,3 +310,25 @@ TEST_F(CLASSNAME(TestContentFilterSubscription, RMW_IMPLEMENTATION), content_fil } } } + +TEST_F( + CLASSNAME( + TestContentFilterSubscription, + RMW_IMPLEMENTATION), create_two_content_filters_with_same_topic_name_and_destroy) { + + // Create another content filter + auto options = rclcpp::SubscriptionOptions(); + + std::string filter_expression = "int32_value > %0"; + std::vector expression_parameters = {"4"}; + + options.content_filter_options.filter_expression = filter_expression; + options.content_filter_options.expression_parameters = expression_parameters; + + auto callback = [](std::shared_ptr) {}; + auto sub_2 = node->create_subscription( + "content_filter_topic", qos, callback, options); + + EXPECT_NE(nullptr, sub_2); + sub_2.reset(); +}