Initial unit tests setup for typed libosrm services
This commit is contained in:
parent
28fe1600ae
commit
1d11701034
@ -342,7 +342,7 @@ target_link_libraries(server-tests osrm ${Boost_LIBRARIES})
|
||||
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES})
|
||||
target_link_libraries(rtree-bench ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES})
|
||||
target_link_libraries(util-tests ${UTIL_LIBRARIES})
|
||||
target_link_libraries(library-tests osrm)
|
||||
target_link_libraries(library-tests osrm ${Boost_LIBRARIES})
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
message(STATUS "Activating OSRM internal tools")
|
||||
|
16
unit_tests/library/args.h
Normal file
16
unit_tests/library/args.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef OSRM_UNIT_TEST_ARGS
|
||||
#define OSRM_UNIT_TEST_ARGS
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
inline std::vector<std::string> get_args()
|
||||
{
|
||||
// Split off argv[0], store actual positional arguments in args
|
||||
const auto argc = boost::unit_test::framework::master_test_suite().argc - 1;
|
||||
const auto argv = boost::unit_test::framework::master_test_suite().argv + 1;
|
||||
|
||||
return {argv, argv + argc};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,8 +1,39 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/match_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(match)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_match) {}
|
||||
BOOST_AUTO_TEST_CASE(test_match)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
/*
|
||||
MatchParameters params;
|
||||
|
||||
json::Object result;
|
||||
|
||||
const auto rc = osrm.Match(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
*/
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
39
unit_tests/library/nearest.cpp
Normal file
39
unit_tests/library/nearest.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/nearest_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(nearest)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_nearest)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
/*
|
||||
NearestParameters params;
|
||||
|
||||
json::Object result;
|
||||
|
||||
const auto rc = osrm.Nearest(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
*/
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
@ -1,8 +1,40 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/route_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(route)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_route) {}
|
||||
BOOST_AUTO_TEST_CASE(test_route)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
RouteParameters params;
|
||||
|
||||
params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
|
||||
params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
|
||||
|
||||
json::Object result;
|
||||
|
||||
const auto rc = osrm.Route(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
39
unit_tests/library/table.cpp
Normal file
39
unit_tests/library/table.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/table_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(table)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_table)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
/*
|
||||
TableParameters params;
|
||||
|
||||
json::Object result;
|
||||
|
||||
const auto rc = osrm.Table(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
*/
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
@ -1,8 +1,40 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/tile_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(tile)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_tile) {}
|
||||
BOOST_AUTO_TEST_CASE(test_tile)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
/*
|
||||
TileParameters params{0, 0, 0};
|
||||
|
||||
// TODO(daniel-j-h): why does the API expect a string?
|
||||
std::string result;
|
||||
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
*/
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -1,8 +1,39 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
#include "osrm/trip_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(trip)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_trip) {}
|
||||
BOOST_AUTO_TEST_CASE(test_trip)
|
||||
{
|
||||
const auto args = get_args();
|
||||
BOOST_REQUIRE_EQUAL(args.size(), 1);
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
EngineConfig config{args[0]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
OSRM osrm{config};
|
||||
|
||||
/*
|
||||
TripParameters params;
|
||||
|
||||
json::Object result;
|
||||
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
*/
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user