GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: unittest/vector.cpp Lines: 13 13 100.0 %
Date: 2024-04-26 13:14:21 Branches: 64 126 50.8 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2020 INRIA
3
//
4
5
#include <pinocchio/math/matrix.hpp>
6
7
#include <boost/variant.hpp> // to avoid C99 warnings
8
9
#include <boost/test/unit_test.hpp>
10
#include <boost/utility/binary.hpp>
11
12
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
13
14
















4
BOOST_AUTO_TEST_CASE(test_isNormalized)
15
{
16
2
  srand(0);
17
18
  using namespace pinocchio;
19
  typedef Eigen::Matrix<double,Eigen::Dynamic,1> Vector;
20
21
2
  const int max_size = 1000;
22
#ifdef NDEBUG
23
  const int max_test = 1e6;
24
#else
25
2
  const int max_test = 1e2;
26
#endif
27
202
  for(int i = 0; i < max_test; ++i)
28
  {
29
200
    const Eigen::DenseIndex size = rand() % max_size + 1; // random vector size
30
400
    Vector vec;
31


200
    vec = Vector::Random(size) + Vector::Constant(size,2.);
32



200
    BOOST_CHECK(!isNormalized(vec));
33
34
200
    vec.normalize();
35



200
    BOOST_CHECK(isNormalized(vec));
36
37
    // Specific check for the Zero vector
38




200
    BOOST_CHECK(!isNormalized(Vector(Vector::Zero(size))));
39
  }
40
2
}
41
42
BOOST_AUTO_TEST_SUITE_END()