GCC Code Coverage Report


Directory: ./
File: unittest/test_diff_actions.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 107 111 96.4%
Branches: 282 608 46.4%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, LAAS-CNRS, New York University,
5 // Max Planck Gesellschaft, INRIA, University of
6 // Oxford, Heriot-Watt University
7 // Copyright note valid unless otherwise stated in individual files.
8 // All rights reserved.
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #define BOOST_TEST_NO_MAIN
12 #define BOOST_TEST_ALTERNATIVE_INIT_API
13
14 #include "factory/diff_action.hpp"
15 #include "unittest_common.hpp"
16
17 using namespace boost::unit_test;
18 using namespace crocoddyl::unittest;
19
20 //----------------------------------------------------------------------------//
21
22 23 void test_check_data(DifferentialActionModelTypes::Type action_type) {
23 // create the model
24
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 DifferentialActionModelFactory factory;
25 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> model =
26
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 factory.create(action_type);
27
28 // Run the print function
29
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 std::ostringstream tmp;
30
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 tmp << *model;
31
32 // create the corresponding data object
33 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data =
34
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 model->createData();
35
36
7/14
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 23 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 23 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 23 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 23 times.
23 BOOST_CHECK(model->checkData(data));
37 23 }
38
39 23 void test_calc_returns_state(DifferentialActionModelTypes::Type action_type) {
40 // create the model
41
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 DifferentialActionModelFactory factory;
42 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> model =
43
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 factory.create(action_type);
44
45 // create the corresponding data object
46 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data =
47
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 model->createData();
48
49 // Generating random state and control vectors
50
1/2
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 const Eigen::VectorXd x = model->get_state()->rand();
51
2/4
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
23 const Eigen::VectorXd u = Eigen::VectorXd::Random(model->get_nu());
52
53 // Getting the state dimension from calc() call
54
3/6
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 model->calc(data, x, u);
55
56
6/12
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 20 taken 23 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 23 times.
✗ Branch 24 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 23 times.
23 BOOST_CHECK(static_cast<std::size_t>(data->xout.size()) ==
57 model->get_state()->get_nv());
58 23 }
59
60 23 void test_calc_returns_a_cost(DifferentialActionModelTypes::Type action_type) {
61 // create the model
62
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 DifferentialActionModelFactory factory;
63 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> model =
64
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 factory.create(action_type);
65
66 // create the corresponding data object and set the cost to nan
67 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data =
68
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 model->createData();
69 23 data->cost = nan("");
70
71 // Getting the cost value computed by calc()
72
1/2
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 const Eigen::VectorXd x = model->get_state()->rand();
73
2/4
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
23 const Eigen::VectorXd u = Eigen::VectorXd::Random(model->get_nu());
74
3/6
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 model->calc(data, x, u);
75
76 // Checking that calc returns a cost value
77
6/12
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 23 times.
23 BOOST_CHECK(!std::isnan(data->cost));
78 23 }
79
80 23 void test_quasi_static(DifferentialActionModelTypes::Type action_type) {
81
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if (action_type ==
82 DifferentialActionModelTypes::
83 DifferentialActionModelFreeFwdDynamics_TalosArm_Squashed)
84 1 return;
85 // create the model
86
1/2
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
22 DifferentialActionModelFactory factory;
87 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> model =
88
1/2
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
22 factory.create(action_type, false);
89
90 // create the corresponding data object and set the cost to nan
91 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data =
92
1/2
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 model->createData();
93
94 // Getting the cost value computed by calc()
95
1/2
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
22 Eigen::VectorXd x = model->get_state()->rand();
96
2/4
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
22 x.tail(model->get_state()->get_nv()).setZero();
97
2/4
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
22 Eigen::VectorXd u = Eigen::VectorXd::Zero(model->get_nu());
98
3/6
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
22 model->quasiStatic(data, u, x);
99
3/6
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
22 model->calc(data, x, u);
100
101 // Check for inactive contacts
102
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 if (action_type == DifferentialActionModelTypes::
103
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
21 DifferentialActionModelContactFwdDynamics_HyQ ||
104 action_type ==
105 DifferentialActionModelTypes::
106
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 DifferentialActionModelContactFwdDynamicsWithFriction_HyQ ||
107 action_type == DifferentialActionModelTypes::
108
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1 times.
19 DifferentialActionModelContactFwdDynamics_Talos ||
109 action_type ==
110 DifferentialActionModelTypes::
111
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 DifferentialActionModelContactFwdDynamicsWithFriction_Talos ||
112 action_type == DifferentialActionModelTypes::
113
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 DifferentialActionModelContactInvDynamics_HyQ ||
114 action_type ==
115 DifferentialActionModelTypes::
116
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1 times.
16 DifferentialActionModelContactInvDynamicsWithFriction_HyQ ||
117 action_type == DifferentialActionModelTypes::
118
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 DifferentialActionModelContactInvDynamics_Talos ||
119 action_type ==
120 DifferentialActionModelTypes::
121 DifferentialActionModelContactInvDynamicsWithFriction_Talos) {
122 boost::shared_ptr<crocoddyl::DifferentialActionModelContactFwdDynamics> m =
123 boost::static_pointer_cast<
124 8 crocoddyl::DifferentialActionModelContactFwdDynamics>(model);
125
2/4
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 m->get_contacts()->changeContactStatus("lf", false);
126
127
3/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 model->quasiStatic(data, u, x);
128
3/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 model->calc(data, x, u);
129
130 // Checking that the acceleration is zero as supposed to be in a quasi
131 // static condition
132
7/14
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 8 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 8 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 8 times.
8 BOOST_CHECK(data->xout.norm() <= 1e-8);
133 8 }
134 22 }
135
136 23 void test_partial_derivatives_against_numdiff(
137 DifferentialActionModelTypes::Type action_type) {
138 // create the model
139
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 DifferentialActionModelFactory factory;
140 boost::shared_ptr<crocoddyl::DifferentialActionModelAbstract> model =
141
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 factory.create(action_type);
142
143 // create the corresponding data object and set the cost to nan
144 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data =
145
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 model->createData();
146
147
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 crocoddyl::DifferentialActionModelNumDiff model_num_diff(model);
148 boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> data_num_diff =
149
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 model_num_diff.createData();
150
151 // Generating random values for the state and control
152
1/2
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 Eigen::VectorXd x = model->get_state()->rand();
153
2/4
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
23 const Eigen::VectorXd u = Eigen::VectorXd::Random(model->get_nu());
154
155 // Computing the action derivatives
156
3/6
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 model->calc(data, x, u);
157
3/6
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 model->calcDiff(data, x, u);
158
3/6
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 23 times.
✗ Branch 8 not taken.
23 model_num_diff.calc(data_num_diff, x, u);
159
3/6
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 23 times.
✗ Branch 8 not taken.
23 model_num_diff.calcDiff(data_num_diff, x, u);
160 // Tolerance defined as in
161 // http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c5-7.pdf
162 23 double tol = std::pow(model_num_diff.get_disturbance(), 1. / 3.);
163
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->h - data_num_diff->h).isZero(tol));
164
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->g - data_num_diff->g).isZero(tol));
165
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Fx - data_num_diff->Fx).isZero(tol));
166
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Fu - data_num_diff->Fu).isZero(tol));
167
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Lx - data_num_diff->Lx).isZero(tol));
168
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Lu - data_num_diff->Lu).isZero(tol));
169
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
23 if (model_num_diff.get_with_gauss_approx()) {
170 BOOST_CHECK((data->Lxx - data_num_diff->Lxx).isZero(tol));
171 BOOST_CHECK((data->Lxu - data_num_diff->Lxu).isZero(tol));
172 BOOST_CHECK((data->Luu - data_num_diff->Luu).isZero(tol));
173 }
174
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Hx - data_num_diff->Hx).isZero(tol));
175
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Hu - data_num_diff->Hu).isZero(tol));
176
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Gx - data_num_diff->Gx).isZero(tol));
177
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Gu - data_num_diff->Gu).isZero(tol));
178
179 // Computing the action derivatives
180
1/2
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 x = model->get_state()->rand();
181
2/4
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
23 model->calc(data, x);
182
2/4
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
23 model->calcDiff(data, x);
183
2/4
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 model_num_diff.calc(data_num_diff, x);
184
2/4
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 model_num_diff.calcDiff(data_num_diff, x);
185
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->h - data_num_diff->h).isZero(tol));
186
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->g - data_num_diff->g).isZero(tol));
187
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Lx - data_num_diff->Lx).isZero(tol));
188
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
23 if (model_num_diff.get_with_gauss_approx()) {
189 BOOST_CHECK((data->Lxx - data_num_diff->Lxx).isZero(tol));
190 }
191
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Hx - data_num_diff->Hx).isZero(tol));
192
8/16
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 23 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 23 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 23 times.
✗ Branch 26 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 23 times.
23 BOOST_CHECK((data->Gx - data_num_diff->Gx).isZero(tol));
193 23 }
194
195 //----------------------------------------------------------------------------//
196
197 23 void register_action_model_unit_tests(
198 DifferentialActionModelTypes::Type action_type) {
199
2/4
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 boost::test_tools::output_test_stream test_name;
200
2/4
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 test_name << "test_" << action_type;
201
4/8
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 23 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 23 times.
✗ Branch 11 not taken.
23 std::cout << "Running " << test_name.str() << std::endl;
202
4/8
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
23 test_suite* ts = BOOST_TEST_SUITE(test_name.str());
203
5/10
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
23 ts->add(BOOST_TEST_CASE(boost::bind(&test_check_data, action_type)));
204
5/10
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
23 ts->add(BOOST_TEST_CASE(boost::bind(&test_calc_returns_state, action_type)));
205
5/10
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
23 ts->add(BOOST_TEST_CASE(boost::bind(&test_calc_returns_a_cost, action_type)));
206
5/10
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
23 ts->add(BOOST_TEST_CASE(
207 boost::bind(&test_partial_derivatives_against_numdiff, action_type)));
208
5/10
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 23 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
23 ts->add(BOOST_TEST_CASE(boost::bind(&test_quasi_static, action_type)));
209
3/6
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
23 framework::master_test_suite().add(ts);
210 23 }
211
212 1 bool init_function() {
213
2/2
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 1 times.
24 for (size_t i = 0; i < DifferentialActionModelTypes::all.size(); ++i) {
214 23 register_action_model_unit_tests(DifferentialActionModelTypes::all[i]);
215 }
216 1 return true;
217 }
218
219 1 int main(int argc, char** argv) {
220 1 return ::boost::unit_test::unit_test_main(&init_function, argc, argv);
221 }
222