Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in two more tests for expand_topic_or_service_name. #1350

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions rclcpp/test/rclcpp/test_expand_topic_or_service_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ TEST(TestExpandTopicOrServiceName, rcl_expand_topic_name_fail_other) {
rclcpp::exceptions::RCLError(RCL_RET_ERROR, rcl_get_error_state(), "error not set"));
}

TEST(TestExpandTopicOrServiceName, rcl_expand_topic_name_fail_invalid_node_name) {
auto mock = mocking_utils::patch_and_return(
"lib:rclcpp", rcl_expand_topic_name, RCL_RET_NODE_INVALID_NAME);
RCLCPP_EXPECT_THROW_EQ(
rclcpp::expand_topic_or_service_name("chatter", "node", "/ns"),
std::runtime_error("invalid rcl node name but valid rmw node name"));
}

TEST(TestExpandTopicOrServiceName, rcl_expand_topic_name_fail_invalid_node_namespace) {
auto mock = mocking_utils::patch_and_return(
"lib:rclcpp", rcl_expand_topic_name, RCL_RET_NODE_INVALID_NAMESPACE);
RCLCPP_EXPECT_THROW_EQ(
rclcpp::expand_topic_or_service_name("chatter", "node", "/ns"),
std::runtime_error("invalid rcl namespace but valid rmw namespace"));
}

TEST(TestExpandTopicOrServiceName, rmw_validate_full_topic_name_fail_other) {
auto mock = mocking_utils::patch_and_return(
"lib:rclcpp", rmw_validate_full_topic_name, RMW_RET_ERROR);
Expand Down