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 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_isNormalized) |
15 |
|
|
{ |
16 |
|
✗ |
srand(0); |
17 |
|
|
|
18 |
|
|
using namespace pinocchio; |
19 |
|
|
typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Vector; |
20 |
|
|
|
21 |
|
✗ |
const int max_size = 1000; |
22 |
|
|
#ifdef NDEBUG |
23 |
|
|
const int max_test = 1e6; |
24 |
|
|
#else |
25 |
|
✗ |
const int max_test = 1e2; |
26 |
|
|
#endif |
27 |
|
✗ |
for (int i = 0; i < max_test; ++i) |
28 |
|
|
{ |
29 |
|
✗ |
const Eigen::DenseIndex size = rand() % max_size + 1; // random vector size |
30 |
|
✗ |
Vector vec; |
31 |
|
✗ |
vec = Vector::Random(size) + Vector::Constant(size, 2.); |
32 |
|
✗ |
BOOST_CHECK(!isNormalized(vec)); |
33 |
|
|
|
34 |
|
✗ |
vec.normalize(); |
35 |
|
✗ |
BOOST_CHECK(isNormalized(vec)); |
36 |
|
|
|
37 |
|
|
// Specific check for the Zero vector |
38 |
|
✗ |
BOOST_CHECK(!isNormalized(Vector(Vector::Zero(size)))); |
39 |
|
|
} |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
BOOST_AUTO_TEST_SUITE_END() |
43 |
|
|
|