Add assertion and adjust unit test expectations check
This commit is contained in:
parent
181eff29c7
commit
26f0b4dc77
@ -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;
|
std::size_t was_waypoint_idx = 0;
|
||||||
for (auto trace_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
for (auto trace_index : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(test_match_split)
|
|||||||
|
|
||||||
MatchParameters params;
|
MatchParameters params;
|
||||||
params.coordinates = get_split_trace_locations();
|
params.coordinates = get_split_trace_locations();
|
||||||
params.timestamps = {1,2,1700,1800};
|
params.timestamps = {1, 2, 1700, 1800};
|
||||||
|
|
||||||
json::Object result;
|
json::Object result;
|
||||||
|
|
||||||
@ -88,6 +88,7 @@ BOOST_AUTO_TEST_CASE(test_match_split)
|
|||||||
const auto &matchings = result.values.at("matchings").get<json::Array>().values;
|
const auto &matchings = result.values.at("matchings").get<json::Array>().values;
|
||||||
const auto &number_of_matchings = matchings.size();
|
const auto &number_of_matchings = matchings.size();
|
||||||
BOOST_CHECK_EQUAL(number_of_matchings, 2);
|
BOOST_CHECK_EQUAL(number_of_matchings, 2);
|
||||||
|
std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
|
||||||
for (const auto &waypoint : tracepoints)
|
for (const auto &waypoint : tracepoints)
|
||||||
{
|
{
|
||||||
if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
|
if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
|
||||||
@ -103,8 +104,15 @@ BOOST_AUTO_TEST_CASE(test_match_split)
|
|||||||
.values.at("legs")
|
.values.at("legs")
|
||||||
.get<json::Array>()
|
.get<json::Array>()
|
||||||
.values;
|
.values;
|
||||||
BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
|
|
||||||
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user