#include <visp3/core/vpConfig.h>
#ifdef VISP_HAVE_CATCH2
#include <limits>
#include <vector>
#include <visp3/core/vpPoseVector.h>
#define CATCH_CONFIG_RUNNER
#include <catch.hpp>
namespace {
void checkSize(
const vpPoseVector& pose,
const std::vector<double>& ref)
{
REQUIRE(pose.
size() == 6);
REQUIRE(pose.
size() == ref.size());
}
void checkData(
const vpPoseVector& pose,
const std::vector<double>& ref)
{
for (
unsigned int i = 0; i < pose.
size(); i++) {
REQUIRE(pose[i] == Approx(ref[i]).epsilon(std::numeric_limits<double>::epsilon()));
}
}
}
TEST_CASE("vpPoseVector size", "[vpColVector]") {
REQUIRE(pose.
size() == 6);
for (
unsigned int i = 0; i < pose.
getRows(); i++) {
REQUIRE(pose[i] == Approx(0).epsilon(std::numeric_limits<double>::epsilon()));
}
}
TEST_CASE("vpPoseVector value assignment", "[vpColVector]") {
std::vector<double> ref(6);
pose[0] = ref[0] = 0.1;
pose[1] = ref[1] = 0.2;
pose[2] = ref[2] = 0.3;
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector constructor", "[vpColVector]") {
std::vector<double> ref(6);
ref[0] = 0.1;
ref[1] = 0.2;
ref[2] = 0.3;
vpPoseVector pose(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]);
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector copy constructor", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]);
checkSize(pose2, ref);
checkData(pose2, ref);
}
TEST_CASE("vpPoseVector object assignment", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]);
checkSize(pose2, ref);
checkData(pose2, ref);
}
TEST_CASE("vpPoseVector set", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]);
pose2.
set(pose1[0], pose1[1], pose1[2], pose1[3], pose1[4], pose1[5]);
checkSize(pose2, ref);
checkData(pose2, ref);
}
TEST_CASE("vpPoseVector constructor t, tu", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector buildFrom t, tu", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector constructor vpHomogeneousMatrix", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector buildFrom vpHomogeneousMatrix", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector constructor t, R", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
TEST_CASE("vpPoseVector buildFrom t, R", "[vpColVector]") {
std::vector<double> ref = { 0.1, 0.2, 0.3,
checkSize(pose, ref);
checkData(pose, ref);
}
int main(int argc, char *argv[])
{
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
return numFailed;
}
#else
#include <iostream>
int main()
{
return 0;
}
#endif