Skip to content

Commit

Permalink
readd testing od empty joint name and no declared parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jul 16, 2024
1 parent c4ce8c4 commit 38df3ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
test_gripper_action_position_controller:
ros__parameters:
joint: "joint1"
joint: "joint1"

test_gripper_action_position_controller_empty_joint:
ros__parameters:
joint: ""
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ void GripperControllerTest::SetUp()

void GripperControllerTest::TearDown() { controller_.reset(nullptr); }

void GripperControllerTest::SetUpController()
void GripperControllerTest::SetUpController(
const std::string & controller_name = "test_gripper_action_position_controller",
controller_interface::return_type expected_result = controller_interface::return_type::OK)
{
const auto result = controller_->init(
"test_gripper_action_position_controller", "", 0, "",
controller_->define_custom_node_options());
ASSERT_EQ(result, controller_interface::return_type::OK);
const auto result =
controller_->init(controller_name, "", 0, "", controller_->define_custom_node_options());
ASSERT_EQ(result, expected_result);

std::vector<LoanedCommandInterface> command_ifs;
command_ifs.emplace_back(this->joint_1_cmd_);
Expand All @@ -61,6 +62,28 @@ void GripperControllerTest::SetUpController()
controller_->assign_interfaces(std::move(command_ifs), std::move(state_ifs));
}

TEST_F(GripperControllerTest, ParametersNotSet)
{
this->SetUpController(
"test_gripper_action_position_controller_no_parameters",
controller_interface::return_type::ERROR);

// configure failed, 'joints' parameter not set
ASSERT_EQ(
this->controller_->on_configure(rclcpp_lifecycle::State()),
controller_interface::CallbackReturn::ERROR);
}

TEST_F(GripperControllerTest, JointParameterIsEmpty)
{
this->SetUpController("test_gripper_action_position_controller_empty_joint");

// configure failed, 'joints' is empty
ASSERT_EQ(
this->controller_->on_configure(rclcpp_lifecycle::State()),
controller_interface::CallbackReturn::ERROR);
}

TEST_F(GripperControllerTest, ConfigureParamsSuccess)
{
this->SetUpController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class GripperControllerTest : public ::testing::Test
void SetUp();
void TearDown();

void SetUpController();
void SetUpController(
const std::string & controller_name, controller_interface::return_type expected_result);
void SetUpHandles();

protected:
Expand Down

0 comments on commit 38df3ea

Please sign in to comment.