Skip to content

Commit

Permalink
Improved Yarp coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Dec 6, 2023
1 parent 4ae0f9b commit c0b93f9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <yarp/dev/IPWMControl.h>
#include <yarp/dev/ICurrentControl.h>
#include <yarp/dev/IRemoteCalibrator.h>
#include <yarp/dev/IControlLimits.h>
#include <yarp/os/Network.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperSingle.h>
Expand All @@ -33,6 +34,7 @@
#include <yarp/dev/tests/IMotorEncodersTest.h>
#include <yarp/dev/tests/IRemoteCalibratorTest.h>
#include <yarp/dev/tests/IJointFaultTest.h>
#include <yarp/dev/tests/IControlLimitsTest.h>

#include <catch2/catch_amalgamated.hpp>
#include <harness.h>
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <yarp/dev/IPWMControl.h>
#include <yarp/dev/ICurrentControl.h>
#include <yarp/dev/IRemoteCalibrator.h>
#include <yarp/dev/IControlLimits.h>
#include <yarp/os/Network.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperMultiple.h>
Expand All @@ -33,6 +34,7 @@
#include <yarp/dev/tests/IMotorEncodersTest.h>
#include <yarp/dev/tests/IRemoteCalibratorTest.h>
#include <yarp/dev/tests/IJointFaultTest.h>
#include <yarp/dev/tests/IControlLimitsTest.h>

#include <catch2/catch_amalgamated.hpp>
#include <harness.h>
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <yarp/dev/ICurrentControl.h>
#include <yarp/dev/IRemoteCalibrator.h>
#include <yarp/dev/IJointFault.h>
#include <yarp/dev/IControlLimits.h>
#include <yarp/os/Network.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperSingle.h>
Expand All @@ -34,6 +35,7 @@
#include <yarp/dev/tests/IMotorEncodersTest.h>
#include <yarp/dev/tests/IRemoteCalibratorTest.h>
#include <yarp/dev/tests/IJointFaultTest.h>
#include <yarp/dev/tests/IControlLimitsTest.h>

#include <catch2/catch_amalgamated.hpp>
#include <harness.h>
Expand Down Expand Up @@ -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"
Expand All @@ -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);
Expand All @@ -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"
{
Expand Down
2 changes: 2 additions & 0 deletions src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(YARP_dev_test_HDRS
IMotorEncodersTest.h
IRemoteCalibratorTest.h
IJointFaultTest.h
IControlLimitsTest.h
)

set(YARP_dev_test_SRCS
Expand All @@ -48,6 +49,7 @@ set(YARP_dev_test_SRCS
IMotorEncodersTest.cpp
IRemoteCalibratorTest.cpp
IJointFaultTest.cpp
IControlLimitsTest.cpp
)

if(TARGET YARP::YARP_math)
Expand Down
6 changes: 6 additions & 0 deletions src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: BSD-3-Clause
*/

#include "IControlLimitsTest.h"
50 changes: 50 additions & 0 deletions src/libYARP_dev/src/yarp/dev/tests/IControlLimitsTest.h
Original file line number Diff line number Diff line change
@@ -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 <memory>
#include <numeric>
#include <vector>

#include <yarp/dev/IAxisInfo.h>
#include <yarp/dev/IControlLimits.h>
#include <catch2/catch_amalgamated.hpp>

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

0 comments on commit c0b93f9

Please sign in to comment.