| 29 | BOOST_AUTO_TEST_SUITE(nearest) |
| 30 | |
| 31 | void test_nearest_response(bool use_json_only_api) |
| 32 | { |
| 33 | auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm"); |
| 34 | |
| 35 | using namespace osrm; |
| 36 | |
| 37 | NearestParameters params; |
| 38 | params.coordinates.push_back(get_dummy_location()); |
| 39 | |
| 40 | json::Object json_result; |
| 41 | const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); |
| 42 | BOOST_REQUIRE(rc == Status::Ok); |
| 43 | |
| 44 | const auto code = std::get<json::String>(json_result.values.at("code")).value; |
| 45 | BOOST_CHECK_EQUAL(code, "Ok"); |
| 46 | |
| 47 | const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values; |
| 48 | BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate |
| 49 | |
| 50 | for (const auto &waypoint : waypoints) |
| 51 | { |
| 52 | const auto &waypoint_object = std::get<json::Object>(waypoint); |
| 53 | const auto distance = std::get<json::Number>(waypoint_object.values.at("distance")).value; |
| 54 | BOOST_CHECK(distance >= 0); |
| 55 | } |
| 56 | } |
| 57 | BOOST_AUTO_TEST_CASE(test_nearest_response_old_api) { test_nearest_response(true); } |
| 58 | BOOST_AUTO_TEST_CASE(test_nearest_response_new_api) { test_nearest_response(false); } |
| 59 |
no test coverage detected