diff --git a/unit_tests/library/route.cpp b/unit_tests/library/route.cpp index 2ea772576..807c26648 100644 --- a/unit_tests/library/route.cpp +++ b/unit_tests/library/route.cpp @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates) BOOST_CHECK_EQUAL(code, "ok"); const auto &waypoints = result.values.at("waypoints").get().values; - BOOST_CHECK(!waypoints.empty()); + BOOST_CHECK(waypoints.size() == params.coordinates.size()); for (const auto &waypoint : waypoints) { @@ -143,4 +143,43 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates) } } +BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component) +{ + const auto args = get_args(); + auto osrm = get_osrm(args.at(0)); + + using namespace osrm; + + const auto locations = get_locations_in_small_component(); + + RouteParameters params; + params.coordinates.push_back(locations.at(0)); + params.coordinates.push_back(locations.at(1)); + params.coordinates.push_back(locations.at(2)); + + json::Object result; + const auto rc = osrm.Route(params, result); + BOOST_CHECK(rc == Status::Ok); + + const auto code = result.values.at("code").get().value; + BOOST_CHECK_EQUAL(code, "ok"); + + const auto &waypoints = result.values.at("waypoints").get().values; + BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); + + for (const auto &waypoint : waypoints) + { + const auto &waypoint_object = waypoint.get(); + + const auto location = waypoint_object.values.at("location").get().values; + const auto longitude = location[0].get().value; + const auto latitude = location[1].get().value; + BOOST_CHECK(longitude >= -180. && longitude <= 180.); + BOOST_CHECK(latitude >= -90. && latitude <= 90.); + + // TODO(daniel-j-h): we could do a Nearest request for each waypoint, verifying + // that we did indeed not snap to the input locations inside the small component. + } +} + BOOST_AUTO_TEST_SUITE_END()