From 7c096888caf92aa7557e1d3efc5448b56d8ce81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Wed, 5 Jun 2024 01:22:38 +0200 Subject: [PATCH] Add test creating two content filter topics with the same topic name (#2546) (#2549) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mario-DL Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com> --- .../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(); +}