Skip to content

Commit

Permalink
improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Nov 30, 2023
1 parent 2e3977d commit ead1caf
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
yarp::dev::tests::exec_iAxisInfo_test_1(iinfo);
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
yarp::dev::tests::exec_iControlMode_test_1(icmd, iinfo);
yarp::dev::tests::exec_iInteractionMode_test_1(iint);
yarp::dev::tests::exec_iInteractionMode_test_1(iint, iinfo);
yarp::dev::tests::exec_iMotor_test_1(imot);
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
yarp::dev::tests::exec_iPidControl_test_1(ipid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]")
yarp::dev::tests::exec_iAxisInfo_test_1(iinfo);
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
yarp::dev::tests::exec_iControlMode_test_1(icmd, iinfo);
yarp::dev::tests::exec_iInteractionMode_test_1(iint);
yarp::dev::tests::exec_iInteractionMode_test_1(iint,iinfo);
yarp::dev::tests::exec_iMotor_test_1(imot);
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
yarp::dev::tests::exec_iPidControl_test_1(ipid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST_CASE("dev::fakeMotionControl", "[yarp::dev]")
yarp::dev::tests::exec_iAxisInfo_test_1(iaxis);
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
yarp::dev::tests::exec_iControlMode_test_1(icmd, iaxis);
yarp::dev::tests::exec_iInteractionMode_test_1(iint);
yarp::dev::tests::exec_iInteractionMode_test_1(iint, iaxis);
yarp::dev::tests::exec_iMotor_test_1(imot);
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
yarp::dev::tests::exec_iPidControl_test_1(ipid);
Expand Down
20 changes: 20 additions & 0 deletions src/libYARP_dev/src/yarp/dev/tests/ICurrentControlTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <yarp/dev/IControlMode.h>
#include <catch2/catch_amalgamated.hpp>

#include <memory>
#include <numeric>
#include <vector>

using namespace yarp::dev;
using namespace yarp::os;

Expand Down Expand Up @@ -43,6 +47,22 @@ namespace yarp::dev::tests

b = icurr->getCurrentRange(0, &min, &max);
CHECK(b);

auto mins = std::vector< double >(axis);
auto maxs = std::vector< double >(axis);
auto currs = std::vector< double >(axis);

b = icurr->getCurrentRanges(mins.data(), maxs.data());
CHECK(b);

b = icurr->getCurrents(currs.data());
CHECK(b);

b = icurr->getRefCurrents(currs.data());
CHECK(b);

b = icurr->setRefCurrents(currs.data());
CHECK(b);
}
}

Expand Down
32 changes: 30 additions & 2 deletions src/libYARP_dev/src/yarp/dev/tests/IInteractionModeTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#ifndef IINTERACTIONMODETEST_H
#define IINTERACTIONMODETEST_H

#include <memory>
#include <numeric>
#include <vector>

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

Expand All @@ -14,11 +19,15 @@ using namespace yarp::os;

namespace yarp::dev::tests
{
inline void exec_iInteractionMode_test_1(IInteractionMode* iint)
inline void exec_iInteractionMode_test_1(IInteractionMode* iint, IAxisInfo* iinfo)
{
REQUIRE(iint != nullptr);
REQUIRE(iinfo != nullptr);

bool b=false;
int ax;
bool b = iinfo->getAxes(&ax);
CHECK(b);
REQUIRE(ax > 0);

yarp::dev::InteractionModeEnum val;
yarp::dev::InteractionModeEnum ret;
Expand All @@ -39,6 +48,25 @@ namespace yarp::dev::tests

b = iint->getInteractionMode(0, &ret);
CHECK(b);

auto modes = std::vector< yarp::dev::InteractionModeEnum>(ax);
b = iint->getInteractionModes(modes.data());
CHECK(b);

auto joints = std::vector<int>(ax);
std::iota(joints.begin(), joints.end(), 0);
b = iint->getInteractionModes(ax, joints.data(), modes.data());
CHECK(b);

for (size_t j = 0; j < ax; j++)
{
modes[j]= yarp::dev::InteractionModeEnum::VOCAB_IM_STIFF;
}
b = iint->setInteractionModes(modes.data());
CHECK(b);
b = iint->setInteractionModes(ax, joints.data(), modes.data());
CHECK(b);

}
}
#endif

0 comments on commit ead1caf

Please sign in to comment.