diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index fab73ad27..86a96c65b 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -97,6 +97,8 @@ class MatchAPI final : public RouteAPI } } + BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1); + std::size_t was_waypoint_idx = 0; for (auto trace_index : util::irange(0UL, parameters.coordinates.size())) { diff --git a/unit_tests/library/match.cpp b/unit_tests/library/match.cpp index 9ac0073b6..972fcf0d6 100644 --- a/unit_tests/library/match.cpp +++ b/unit_tests/library/match.cpp @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(test_match_split) MatchParameters params; params.coordinates = get_split_trace_locations(); - params.timestamps = {1,2,1700,1800}; + params.timestamps = {1, 2, 1700, 1800}; json::Object result; @@ -88,6 +88,7 @@ BOOST_AUTO_TEST_CASE(test_match_split) const auto &matchings = result.values.at("matchings").get().values; const auto &number_of_matchings = matchings.size(); BOOST_CHECK_EQUAL(number_of_matchings, 2); + std::size_t current_matchings_index = 0, expected_waypoint_index = 0; for (const auto &waypoint : tracepoints) { if (waypoint.is>()) @@ -103,8 +104,15 @@ BOOST_AUTO_TEST_CASE(test_match_split) .values.at("legs") .get() .values; - BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1); + BOOST_CHECK_LT(matchings_index, number_of_matchings); + + expected_waypoint_index = + (current_matchings_index != matchings_index) ? 0 : expected_waypoint_index; + BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index); + + current_matchings_index = matchings_index; + ++expected_waypoint_index; } else {