#include <cmath>
#include <vector>
#include <limits>
#include <visp3/core/vpPoseVector.h>
bool test(
const std::string &s,
const vpArray2D<double> &A,
const std::vector<double> &bench)
{
static unsigned int cpt = 0;
std::cout << "** Test " << ++cpt << std::endl;
std::cout << s <<
"(" << A.
getRows() <<
"," << A.
getCols() <<
") =" << A << std::endl;
if(bench.size() != A.
size()) {
std::cout << "Test fails: bad size wrt bench" << std::endl;
return false;
}
for (
unsigned int i=0; i<A.
size(); i++) {
if (std::fabs(A.
data[i]-bench[i]) > std::fabs(A.
data[i])*std::numeric_limits<double>::epsilon()) {
std::cout << "Test fails: bad content" << std::endl;
return false;
}
}
return true;
}
int main()
{
{
std::vector<double> bench(6,0);
int err = 1;
if (test("p", p, bench) == false)
return err;
p[0] = bench[0] = 0.1;
p[1] = bench[1] = 0.2;
p[2] = bench[2] = 0.3;
if (test("p", p, bench) == false)
return err;
if (test("p1", p1, bench) == false)
return err;
if (test("p2", p2, bench) == false)
return err;
if (test("p3", p3, bench) == false)
return err;
p4.
set(p[0], p[1], p[2], p[3], p[4], p[5]);
if (test("p4", p4, bench) == false)
return err;
if (test("p5", p5, bench) == false)
return err;
if (test("p6", p6, bench) == false)
return err;
if (test("p7", p7, bench) == false)
return err;
if (test("p8", p8, bench) == false)
return err;
if (test("p9", p9, bench) == false)
return err;
if (test("p10", p10, bench) == false)
return err;
}
std::cout << "All tests succeed" << std::endl;
return 0;
}