Skip to content

Commit a58aa8f

Browse files
committed
[unittest] Added safe_diff/integrate unittest
1 parent 30a9543 commit a58aa8f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

unittest/test_states.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ void test_integrate_against_difference(StateModelTypes::Type state_type) {
6969
Eigen::VectorXd dxi(state->get_ndx());
7070
state->diff(x1, x2, dx);
7171
state->integrate(x1, dx, x2i);
72-
state->diff(x2i, x2, dxi);
73-
7472
// Checking that both states agree
73+
state->diff(x2i, x2, dxi);
74+
BOOST_CHECK(dxi.isZero(1e-9));
75+
state->safe_diff(x2i, x2, dxi);
7576
BOOST_CHECK(dxi.isZero(1e-9));
7677

7778
// Checking that casted computation is the same
@@ -103,9 +104,10 @@ void test_difference_against_integrate(StateModelTypes::Type state_type) {
103104
Eigen::VectorXd xidx(state->get_nx());
104105
Eigen::VectorXd dxd(state->get_ndx());
105106
state->integrate(x, dx, xidx);
106-
state->diff(x, xidx, dxd);
107-
108107
// Checking that both states agree
108+
state->diff(x, xidx, dxd);
109+
BOOST_CHECK((dxd - dx).isZero(1e-9));
110+
state->safe_diff(x, xidx, dxd);
109111
BOOST_CHECK((dxd - dx).isZero(1e-9));
110112

111113
// Checking that casted computation is the same

0 commit comments

Comments
 (0)