From c0b93f90f1d778d10c77ebe439022e413c6cc747 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Wed, 6 Dec 2023 16:00:51 +0100 Subject: [PATCH] Improved Yarp coverage --- .../tests/RemoteControlBoard_test.cpp | 5 ++ .../tests/controlBoardRemapper_t2_test.cpp | 5 ++ .../tests/fakeMotionControl_test.cpp | 5 ++ .../src/yarp/dev/tests/CMakeLists.txt | 2 + .../src/yarp/dev/tests/IControlLimitsTest.cpp | 6 +++ .../src/yarp/dev/tests/IControlLimitsTest.h | 50 +++++++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.cpp create mode 100644 src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.h diff --git a/src/devices/RemoteControlBoard/tests/RemoteControlBoard_test.cpp b/src/devices/RemoteControlBoard/tests/RemoteControlBoard_test.cpp index 59f4a7f346..ccf29005cc 100644 --- a/src/devices/RemoteControlBoard/tests/RemoteControlBoard_test.cpp +++ b/src/devices/RemoteControlBoard/tests/RemoteControlBoard_test.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -67,6 +69,7 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]") IPWMControl* ipwm = nullptr; ICurrentControl* icurr = nullptr; IJointFault* ifault = nullptr; + IControlLimits* ilims = nullptr; //IRemoteCalibrator* iremotecalib = nullptr; ////////"Checking opening fakeMotionControl and controlBoard_nws_yarp polydrivers" @@ -120,6 +123,7 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]") ddnwc.view(ipwm); REQUIRE(ipwm); ddnwc.view(icurr); REQUIRE(icurr); ddnwc.view(ifault); REQUIRE(ifault); + ddnwc.view(ilims); REQUIRE(ilims); //ddnwc.view(icalib); REQUIRE(iremotecalib); yarp::dev::tests::exec_iPositionControl_test_1(ipos,icmd); @@ -137,6 +141,7 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]") yarp::dev::tests::exec_iCurrentControl_test_1(icurr,icmd); //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib); yarp::dev::tests::exec_iJointFault_test_1(ifault); + yarp::dev::tests::exec_iControlLimits_test1(ilims, iinfo); //"Close all polydrivers and check" { diff --git a/src/devices/controlBoardRemapper/tests/controlBoardRemapper_t2_test.cpp b/src/devices/controlBoardRemapper/tests/controlBoardRemapper_t2_test.cpp index 28db274365..c52f0519ec 100644 --- a/src/devices/controlBoardRemapper/tests/controlBoardRemapper_t2_test.cpp +++ b/src/devices/controlBoardRemapper/tests/controlBoardRemapper_t2_test.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -65,6 +67,7 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]") IPWMControl* ipwm = nullptr; ICurrentControl* icurr = nullptr; IJointFault* ifault = nullptr; + IControlLimits* ilims = nullptr; //IRemoteCalibrator* iremotecalib = nullptr; ////////"Checking opening map2DServer and map2DClient polydrivers" @@ -103,6 +106,7 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]") ddremapper.view(ipwm); REQUIRE(ipwm); ddremapper.view(icurr); REQUIRE(icurr); ddremapper.view(ifault); REQUIRE(ifault); + ddremapper.view(ilims); REQUIRE(ilims); //ddremapper.view(iremotecalib); REQUIRE(iremotecalib); yarp::dev::tests::exec_iPositionControl_test_1(ipos, icmd); @@ -120,6 +124,7 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]") yarp::dev::tests::exec_iCurrentControl_test_1(icurr, icmd); //yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib); yarp::dev::tests::exec_iJointFault_test_1(ifault); + yarp::dev::tests::exec_iControlLimits_test1(ilims, iinfo); //"Close all polydrivers and check" { diff --git a/src/devices/fakeMotionControl/tests/fakeMotionControl_test.cpp b/src/devices/fakeMotionControl/tests/fakeMotionControl_test.cpp index ffed95d4de..736a4df608 100644 --- a/src/devices/fakeMotionControl/tests/fakeMotionControl_test.cpp +++ b/src/devices/fakeMotionControl/tests/fakeMotionControl_test.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include @@ -64,6 +66,7 @@ TEST_CASE("dev::fakeMotionControl", "[yarp::dev]") IPWMControl* ipwm = nullptr; ICurrentControl* icurr = nullptr; IJointFault* ifault = nullptr; + IControlLimits* ilims = nullptr; //IRemoteCalibrator* icalib = nullptr; ////////"Checking opening polydrivers" @@ -88,6 +91,7 @@ TEST_CASE("dev::fakeMotionControl", "[yarp::dev]") ddmc.view(ipwm); REQUIRE(ipwm); ddmc.view(icurr); REQUIRE(icurr); ddmc.view(ifault); REQUIRE(ifault); + ddmc.view(ilims); REQUIRE(ilims); //ddmc.view(iremotecalib); REQUIRE(iremotecalib); yarp::dev::tests::exec_iPositionControl_test_1(ipos, icmd); @@ -105,6 +109,7 @@ TEST_CASE("dev::fakeMotionControl", "[yarp::dev]") yarp::dev::tests::exec_iCurrentControl_test_1(icurr, icmd); //yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib); yarp::dev::tests::exec_iJointFault_test_1(ifault); + yarp::dev::tests::exec_iControlLimits_test1(ilims, iinfo); //"Close all polydrivers and check" { diff --git a/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt b/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt index 1e88dd40a5..5eebe6dde0 100644 --- a/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt +++ b/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt @@ -25,6 +25,7 @@ set(YARP_dev_test_HDRS IMotorEncodersTest.h IRemoteCalibratorTest.h IJointFaultTest.h + IControlLimitsTest.h ) set(YARP_dev_test_SRCS @@ -48,6 +49,7 @@ set(YARP_dev_test_SRCS IMotorEncodersTest.cpp IRemoteCalibratorTest.cpp IJointFaultTest.cpp + IControlLimitsTest.cpp ) if(TARGET YARP::YARP_math) diff --git a/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.cpp b/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.cpp new file mode 100644 index 0000000000..eb8cc6c8e3 --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.cpp @@ -0,0 +1,6 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "IControlLimitsTest.h" diff --git a/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.h b/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.h new file mode 100644 index 0000000000..266769c4af --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.h @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ICONTROLLIMITSTEST_H +#define ICONTROLLIMITSTEST_H + +#include +#include +#include + +#include +#include +#include + +using namespace yarp::dev; +using namespace yarp::os; + +namespace yarp::dev::tests +{ + inline void exec_iControlLimits_test1(IControlLimits* ilims, IAxisInfo* iinfo) + { + REQUIRE(ilims != nullptr); + REQUIRE(iinfo != nullptr); + + bool b; + int ax; + + b = iinfo->getAxes(&ax); + CHECK(b); + REQUIRE(ax > 0); + + double min=0; + double max=0; + b = ilims->getLimits (0, &min, &max); + CHECK(b); + + b = ilims->getVelLimits(0, &min, &max); + CHECK(b); + + b = ilims->setLimits(0, min, max); + CHECK(b); + + b = ilims->setVelLimits(0, min, max); + CHECK(b); + } +} + +#endif