From a3d2592843c1091f257f90faef0bcc32bd935b1f Mon Sep 17 00:00:00 2001 From: Alexander Gutenkunst Date: Tue, 16 Jun 2020 17:02:19 +0200 Subject: [PATCH] Use Macro for MATCHER_P generation --- .../pilz_joint_trajectory_controller_impl.h | 7 +++--- ...ttest_pilz_joint_trajectory_controller.cpp | 4 ++-- .../include/pilz_testutils/logger_mock.h | 23 ++++++++----------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/pilz_control/include/pilz_control/pilz_joint_trajectory_controller_impl.h b/pilz_control/include/pilz_control/pilz_joint_trajectory_controller_impl.h index ba11b37d4..e880a4f11 100644 --- a/pilz_control/include/pilz_control/pilz_joint_trajectory_controller_impl.h +++ b/pilz_control/include/pilz_control/pilz_joint_trajectory_controller_impl.h @@ -279,10 +279,9 @@ template void PilzJointTrajectoryController::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 diff --git a/pilz_control/test/unittest_pilz_joint_trajectory_controller.cpp b/pilz_control/test/unittest_pilz_joint_trajectory_controller.cpp index 192da1157..4ff24490e 100644 --- a/pilz_control/test/unittest_pilz_joint_trajectory_controller.cpp +++ b/pilz_control/test/unittest_pilz_joint_trajectory_controller.cpp @@ -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. @@ -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."), _)) diff --git a/pilz_testutils/include/pilz_testutils/logger_mock.h b/pilz_testutils/include/pilz_testutils/logger_mock.h index 4a92bff85..7d37097ed 100644 --- a/pilz_testutils/include/pilz_testutils/logger_mock.h +++ b/pilz_testutils/include/pilz_testutils/logger_mock.h @@ -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