Compare commits
1 Commits
native_buf
...
fujitatomo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78bcd2f115 |
@@ -67,13 +67,7 @@ Rate::sleep()
|
||||
// Calculate the time to sleep
|
||||
auto time_to_sleep = next_interval - now;
|
||||
// Sleep (will get interrupted by ctrl-c, may not sleep full time)
|
||||
try {
|
||||
// If the context is invalid, an exception will be thrown.
|
||||
clock_->sleep_for(time_to_sleep);
|
||||
} catch (const std::runtime_error & e) {
|
||||
// If it didn't sleep the full time, return false
|
||||
return false;
|
||||
}
|
||||
clock_->sleep_for(time_to_sleep);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,12 +173,3 @@ TEST_F(TestRate, incorrect_constuctor) {
|
||||
rclcpp::Rate rate(rclcpp::Duration(-1, 0)),
|
||||
std::invalid_argument("period must be greater than 0"));
|
||||
}
|
||||
|
||||
TEST(TestRateBasic, invalid_context) {
|
||||
rclcpp::init(0, nullptr);
|
||||
rclcpp::Rate rate(1.0);
|
||||
ASSERT_TRUE(rate.sleep());
|
||||
rclcpp::shutdown();
|
||||
EXPECT_NO_THROW(rate.sleep());
|
||||
ASSERT_FALSE(rate.sleep());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user