Skip to content

Commit

Permalink
refactor corrected depth check for prefix in parameter_fixtures.hpp (#…
Browse files Browse the repository at this point in the history
…529)

Signed-off-by: leeminju531 <[email protected]>
  • Loading branch information
leeminju531 authored Sep 18, 2023
1 parent 378269b commit 6b89236
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions test_rclcpp/test/parameter_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,14 @@ void test_get_parameters_sync(
EXPECT_STREQ("foo", prefix.c_str());
}

printf("Listing parameters with depth of 1\n");
// Test different depth
printf("Listing parameters with depth 1 and a prefix 'foo'\n");
// Test relative depth to the given prefixes
auto parameters_and_prefixes4 =
parameters_client->list_parameters({"foo"}, 1, std::chrono::seconds(1));
for (auto & name : parameters_and_prefixes4.names) {
EXPECT_EQ(name, "foo");
}
for (auto & prefix : parameters_and_prefixes4.prefixes) {
EXPECT_STREQ("foo", prefix.c_str());
}

printf("Listing parameters with depth of 2\n");
// Test different depth
auto parameters_and_prefixes5 =
parameters_client->list_parameters({"foo"}, 2, std::chrono::seconds(1));
for (auto & name : parameters_and_prefixes5.names) {
EXPECT_TRUE(name == "foo" || name == "foo.first" || name == "foo.second");
}
for (auto & prefix : parameters_and_prefixes5.prefixes) {
for (auto & prefix : parameters_and_prefixes4.prefixes) {
EXPECT_STREQ("foo", prefix.c_str());
}

Expand Down Expand Up @@ -288,31 +277,18 @@ void test_get_parameters_async(
EXPECT_STREQ("foo", prefix.c_str());
}

printf("Listing parameters with depth 1\n");
// Test different depth
printf("Listing parameters with depth 1 and a prefix 'foo'\n");
// Test relative depth to the given prefixes
auto result4 = parameters_client->list_parameters({"foo"}, 1);
rclcpp::spin_until_future_complete(node, result4);
auto parameters_and_prefixes4 = result4.get();
for (auto & name : parameters_and_prefixes4.names) {
EXPECT_EQ(name, "foo");
}
for (auto & prefix : parameters_and_prefixes4.prefixes) {
EXPECT_STREQ("foo", prefix.c_str());
}

// Test different depth
printf("Listing parameters with depth 2\n");
auto result4a = parameters_client->list_parameters({"foo"}, 2);
rclcpp::spin_until_future_complete(node, result4a);
auto parameters_and_prefixes4a = result4a.get();
for (auto & name : parameters_and_prefixes4a.names) {
EXPECT_TRUE(name == "foo" || name == "foo.first" || name == "foo.second");
}
for (auto & prefix : parameters_and_prefixes4a.prefixes) {
for (auto & prefix : parameters_and_prefixes4.prefixes) {
EXPECT_STREQ("foo", prefix.c_str());
}


printf("Getting parameters\n");
// Get a few of the parameters just set.
auto result2 = parameters_client->get_parameters({"foo", "bar", "baz"});
Expand Down

0 comments on commit 6b89236

Please sign in to comment.