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 71900d2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
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 71900d2

Please sign in to comment.