Add route fixture test

This commit is contained in:
Patrick Niklaus
2016-03-24 21:02:55 +01:00
parent b65ba5c394
commit a964bec0f8
6 changed files with 237 additions and 9 deletions
+27
View File
@@ -0,0 +1,27 @@
#ifndef UNIT_TESTS_JSON_EQUAL
#define UNIT_TESTS_JSON_EQUAL
#include <boost/test/included/unit_test.hpp>
#include "util/json_deep_compare.hpp"
boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference,
const osrm::util::json::Value &result)
{
std::string reason;
auto is_same = osrm::util::json::compare(reference, result, reason);
if (!is_same)
{
boost::test_tools::predicate_result res(false);
res.message() << reason;
return res;
}
return true;
}
#define CHECK_EQUAL_JSON(reference, result) BOOST_CHECK(compareJSON(reference, result));
#endif
+47
View File
@@ -3,6 +3,7 @@
#include "args.hpp"
#include "fixture.hpp"
#include "equal_json.hpp"
#include "coordinates.hpp"
#include "osrm/route_parameters.hpp"
@@ -15,6 +16,52 @@
BOOST_AUTO_TEST_SUITE(route)
BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
RouteParameters params;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
json::Object result;
const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok);
json::Object reference{
{{"code", "ok"},
{"waypoints",
json::Array{{json::Object{{{"name", ""}, {"location", json::Array{}}, {"hint", ""}}},
json::Object{{{"name", ""}, {"location", json::Array{}}, {"hint", ""}}}}}},
{"routes", json::Array{{json::Object{
{{"distance", 0.},
{"duration", 0.},
{"geometry", ""},
{"legs", json::Array{{json::Object{
{{"distance", 0.},
{"duration", 0.},
{"summary", ""},
{"steps", json::Array{{json::Object{
{{"duration", 0.},
{"distance", 0.},
{"geometry", ""},
{"name", ""},
{"mode", "driving"},
{"maneuver", json::Object{{
{"type", "depart"},
{"location", json::Array{}},
{"modifier", ""},
{"bearing_before", 0.},
{"bearing_after", 0.},
{"exit", 0},
}}}}}}}}}}}}}}}}}}}};
CHECK_EQUAL_JSON(reference, result);
}
BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
{
const auto args = get_args();
+2 -4
View File
@@ -2,6 +2,7 @@
#include <boost/test/test_case_template.hpp>
#include "args.hpp"
#include "fixture.hpp"
#include "osrm/table_parameters.hpp"
@@ -20,10 +21,7 @@ BOOST_AUTO_TEST_CASE(test_table)
using namespace osrm;
EngineConfig config{args[0]};
config.use_shared_memory = false;
OSRM osrm{config};
auto osrm = getOSRM(args[0]);
/*
TableParameters params;
+2 -4
View File
@@ -2,6 +2,7 @@
#include <boost/test/test_case_template.hpp>
#include "args.hpp"
#include "fixture.hpp"
#include "osrm/trip_parameters.hpp"
@@ -20,10 +21,7 @@ BOOST_AUTO_TEST_CASE(test_trip)
using namespace osrm;
EngineConfig config{args[0]};
config.use_shared_memory = false;
OSRM osrm{config};
auto osrm = getOSRM(args[0]);
/*
TripParameters params;