Skip to content

Commit

Permalink
add tests for prune_requests_older_than
Browse files Browse the repository at this point in the history
  • Loading branch information
akela1101 committed Nov 23, 2022
1 parent bb178d6 commit 7176087
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rclcpp/test/rclcpp/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,26 @@ TEST_F(TestClientWithServer, test_client_remove_pending_request) {
EXPECT_TRUE(client->remove_pending_request(future));
}

TEST_F(TestClientWithServer, prune_requests_older_than_no_pruned) {
auto client = node->create_client<test_msgs::srv::Empty>(service_name);
auto request = std::make_shared<test_msgs::srv::Empty::Request>();
auto future = client->async_send_request(request);
auto time = std::chrono::system_clock::now() + 1s;

EXPECT_EQ(size_t(1), client->prune_requests_older_than(time));
}

TEST_F(TestClientWithServer, prune_requests_older_than_with_pruned) {
auto client = node->create_client<test_msgs::srv::Empty>(service_name);
auto request = std::make_shared<test_msgs::srv::Empty::Request>();
auto future = client->async_send_request(request);
auto time = std::chrono::system_clock::now() + 1s;

std::vector<int64_t> pruned_requests;
EXPECT_EQ(size_t(1), client->prune_requests_older_than(time, &pruned_requests));
EXPECT_EQ(size_t(1), pruned_requests.size());
}

TEST_F(TestClientWithServer, async_send_request_rcl_send_request_error) {
// Checking rcl_send_request in rclcpp::Client::async_send_request()
auto mock = mocking_utils::patch_and_return("lib:rclcpp", rcl_send_request, RCL_RET_ERROR);
Expand Down

0 comments on commit 7176087

Please sign in to comment.