Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Use Macro for MATCHER_P generation
Browse files Browse the repository at this point in the history
  • Loading branch information
agutenkunst committed Jun 16, 2020
1 parent 0548379 commit a3d2592
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,9 @@ template <class SegmentImpl, class HardwareInterface>
void PilzJointTrajectoryController<SegmentImpl, HardwareInterface>::trajectoryCommandCB(
const JointTrajectoryConstPtr& /*msg*/)
{
ROS_WARN_NAMED(this->name_,
"For safety reasons the trajectory command interface is deactivated"
" (for more information see https://github.com/ros-controls/ros_controllers/issues/493)."
" Please use the action interface instead.");
ROS_WARN_NAMED(this->name_, "For safety reasons the trajectory command interface is deactivated"
" (for more information see https://github.com/ros-controls/ros_controllers/issues/493)."
" Please use the action interface instead.");
}

} // namespace pilz_joint_trajectory_controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ TEST_P(PilzJointTrajectoryControllerIsExecutingTest, testActionGoalExecution)
EXPECT_FALSE(is_executing_result) << "There should be no execution to detect";
}

using pilz_testutils::IsWarn;
using pilz_testutils::IsWARN;
using ::testing::_;
/**
* @brief Tests that the controller does not execute if a trajectory is sent via command interface.
Expand All @@ -510,7 +510,7 @@ TEST_P(PilzJointTrajectoryControllerIsExecutingTest, testTrajCommandExecution)

pilz_testutils::ROSLogExtender ros_log_extender;
EXPECT_CALL(*ros_log_extender,
append(IsWarn("For safety reasons the trajectory command interface is deactivated "
append(IsWARN("For safety reasons the trajectory command interface is deactivated "
"(for more information see https://github.com/ros-controls/ros_controllers/issues/493). "
"Please use the action interface instead."),
_))
Expand Down
23 changes: 10 additions & 13 deletions pilz_testutils/include/pilz_testutils/logger_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,17 @@ class LoggerMock : public log4cxx::AppenderSkeleton

namespace levels = ::ros::console::levels;

MATCHER_P(IsInfo, msg, "")
{
return arg->getLevel()->toInt() == log4cxx::Level::INFO_INT && std::string(msg) == arg->getMessage();
}

MATCHER_P(IsWarn, msg, "")
{
return arg->getLevel()->toInt() == log4cxx::Level::WARN_INT && std::string(msg) == arg->getMessage();
}
#define GENERATE_LOGMESSAGE_MATCHER_P(severity) \
MATCHER_P(Is##severity, msg, "") \
{ \
return arg->getLevel()->toInt() == log4cxx::Level::severity##_INT && std::string(msg) == arg->getMessage(); \
}

MATCHER_P(IsError, msg, "")
{
return arg->getLevel()->toInt() == log4cxx::Level::ERROR_INT && std::string(msg) == arg->getMessage();
}
GENERATE_LOGMESSAGE_MATCHER_P(DEBUG)
GENERATE_LOGMESSAGE_MATCHER_P(INFO)
GENERATE_LOGMESSAGE_MATCHER_P(WARN)
GENERATE_LOGMESSAGE_MATCHER_P(ERROR)
GENERATE_LOGMESSAGE_MATCHER_P(FATAL)

} // namespace pilz_testutils

Expand Down

0 comments on commit a3d2592

Please sign in to comment.