Skip to content

Commit

Permalink
Add test creating two content filter topics with the same topic name (#…
Browse files Browse the repository at this point in the history
…230) (#233)

Signed-off-by: Mario-DL <[email protected]>
Signed-off-by: Mario Dominguez <[email protected]>
Co-authored-by: Mario Domínguez López <[email protected]>
  • Loading branch information
ahcorde and Mario-DL authored Jun 4, 2024
1 parent 6f8bc6b commit 16e14d1
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test_rmw_implementation/test/test_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,3 +1707,46 @@ TEST_F(TestContentFilterSubscriptionUse, content_filter_reset) {
}
}
}

TEST_F(TestContentFilterSubscriptionUse, create_two_filters_with_same_topic_name_and_destroy) {
if (sub->is_cft_enabled) {
auto allocator = rcutils_get_default_allocator();
rmw_subscription_options_t options = rmw_get_default_subscription_options();

rmw_subscription_content_filter_options_t * content_filter_options =
static_cast<rmw_subscription_content_filter_options_t *>(
allocator.allocate(
sizeof(rmw_subscription_content_filter_options_t), allocator.state));

OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
allocator.deallocate(content_filter_options, allocator.state);
});

*content_filter_options = rmw_get_zero_initialized_content_filter_options();

EXPECT_EQ(
RMW_RET_OK, rmw_subscription_content_filter_options_init(
filter_expression,
expression_parameters_count,
expression_parameters,
&allocator,
content_filter_options));

OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
EXPECT_EQ(
RMW_RET_OK,
rmw_subscription_content_filter_options_fini(content_filter_options, &allocator));
});

options.content_filter_options = content_filter_options;

// Create another subscription with content filter in the same topic
auto sub_2 = rmw_create_subscription(node, ts, topic_name, &qos_profile, &options);
ASSERT_NE(nullptr, sub_2) << rmw_get_error_string().str;

rmw_ret_t ret = rmw_destroy_subscription(node, sub_2);
EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
}
}

0 comments on commit 16e14d1

Please sign in to comment.