Skip to content

Commit

Permalink
core: Improve unit test for fold_position()
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 5, 2020
1 parent 77720e0 commit 4b1ecae
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/core/unit_tests/grid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,32 @@ BOOST_AUTO_TEST_CASE(fold_position_test) {
box.set_periodic(0, true);
box.set_periodic(1, true);
box.set_periodic(2, false);
Utils::Vector3d pos{1., 5., 7.};
Utils::Vector3i img{0, 1, 1};
Utils::Vector3d expected_pos{1., 1., 7.};
Utils::Vector3i expected_img{0, 2, 1};

fold_position(pos, img, box);
/* Wrapped */
{
Utils::Vector3d pos{-1.9, 4.1, 7.};
Utils::Vector3i img{0, 1, 1};
Utils::Vector3d const expected_pos{0.1, 0.1, 7.};
Utils::Vector3i const expected_img{-1, 2, 1};

fold_position(pos, img, box);

BOOST_CHECK_SMALL((pos - expected_pos).norm(), 3 * epsilon<double>);
BOOST_CHECK_EQUAL((img - expected_img).norm2(), 0);
}

BOOST_CHECK_SMALL((pos - expected_pos).norm(), epsilon<double>);
BOOST_CHECK_EQUAL((img - expected_img).norm2(), 0);
/* Not wrapped */
{
Utils::Vector3d pos{1., 3., 7.};
Utils::Vector3i img{0, -1, -1};
Utils::Vector3d const expected_pos{1., 3., 7.};
Utils::Vector3i const expected_img{0, -1, -1};

fold_position(pos, img, box);

BOOST_CHECK_SMALL((pos - expected_pos).norm(), 3 * epsilon<double>);
BOOST_CHECK_EQUAL((img - expected_img).norm2(), 0);
}
}

BOOST_AUTO_TEST_CASE(regular_decomposition_test) {
Expand Down

0 comments on commit 4b1ecae

Please sign in to comment.