#include "../common/range_tools.hpp" #include "util/permutation.hpp" #include #include #include #include #include BOOST_AUTO_TEST_SUITE(permutation_test) using namespace osrm; using namespace osrm::util; BOOST_AUTO_TEST_CASE(basic_permuation) { // cycles (0 3 2 1 4 8) (5) (6 9 7) // 0 1 2 3 4 5 6 7 8 9 std::vector values{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; const std::vector permutation{3, 4, 1, 2, 8, 5, 9, 6, 0, 7}; std::vector reference{9, 3, 4, 1, 2, 6, 8, 10, 5, 7}; inplacePermutation(values.begin(), values.end(), permutation); CHECK_EQUAL_COLLECTIONS(values, reference); } BOOST_AUTO_TEST_SUITE_END()