Increase coverage of guard_condition.cpp to 100% (#1369)
Signed-off-by: Stephen Brawner <brawner@gmail.com>
This commit is contained in:
parent
17c53a16f0
commit
b3f50460f4
2 changed files with 19 additions and 2 deletions
|
@ -567,7 +567,7 @@ endif()
|
|||
ament_add_gtest(test_guard_condition rclcpp/test_guard_condition.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_guard_condition)
|
||||
target_link_libraries(test_guard_condition ${PROJECT_NAME})
|
||||
target_link_libraries(test_guard_condition ${PROJECT_NAME} mimick)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_wait_set rclcpp/test_wait_set.cpp
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
|
||||
#include "../mocking_utils/patch.hpp"
|
||||
|
||||
class TestGuardCondition : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
@ -54,6 +56,14 @@ TEST_F(TestGuardCondition, construction_and_destruction) {
|
|||
(void)gc;
|
||||
}, rclcpp::exceptions::RCLInvalidArgument);
|
||||
}
|
||||
|
||||
{
|
||||
auto mock = mocking_utils::inject_on_return(
|
||||
"lib:rclcpp", rcl_guard_condition_fini, RCL_RET_ERROR);
|
||||
auto gc = std::make_shared<rclcpp::GuardCondition>();
|
||||
// This just logs an error on destruction
|
||||
EXPECT_NO_THROW(gc.reset());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -82,6 +92,13 @@ TEST_F(TestGuardCondition, get_rcl_guard_condition) {
|
|||
TEST_F(TestGuardCondition, trigger) {
|
||||
{
|
||||
auto gc = std::make_shared<rclcpp::GuardCondition>();
|
||||
gc->trigger();
|
||||
EXPECT_NO_THROW(gc->trigger());
|
||||
|
||||
{
|
||||
auto mock = mocking_utils::patch_and_return(
|
||||
"lib:rclcpp", rcl_trigger_guard_condition, RCL_RET_ERROR);
|
||||
auto gc = std::make_shared<rclcpp::GuardCondition>();
|
||||
EXPECT_THROW(gc->trigger(), rclcpp::exceptions::RCLError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue