Make initialization fail with a specific exception if the dataset isn't compatible with the algorithm being used, rather than crashing when a query occurs.
This commit is contained in:
committed by
Patrick Niklaus
parent
3d77714c36
commit
5026741652
@@ -0,0 +1,34 @@
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "fixture.hpp"
|
||||
|
||||
#include "osrm/exception.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(table)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_incompatible_with_mld)
|
||||
{
|
||||
// Can't use the MLD algorithm with CH data
|
||||
BOOST_CHECK_THROW(
|
||||
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::MLD),
|
||||
osrm::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_incompatible_with_corech)
|
||||
{
|
||||
// Note - CH-only data can't be used with the CoreCH algorithm
|
||||
BOOST_CHECK_THROW(
|
||||
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH),
|
||||
osrm::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_incompatible_with_ch)
|
||||
{
|
||||
// Can't use the CH algorithm with MLD data
|
||||
BOOST_CHECK_THROW(
|
||||
getOSRM(OSRM_TEST_DATA_DIR "/mld/monaco.osrm", osrm::EngineConfig::Algorithm::CH),
|
||||
osrm::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -9,11 +9,14 @@
|
||||
// I couldn't get Boost.UnitTest to provide a test suite level fixture with custom
|
||||
// arguments per test suite (osrm base path from argv), so this has to suffice.
|
||||
|
||||
inline osrm::OSRM getOSRM(const std::string &base_path)
|
||||
inline osrm::OSRM
|
||||
getOSRM(const std::string &base_path,
|
||||
osrm::EngineConfig::Algorithm algorithm = osrm::EngineConfig::Algorithm::CH)
|
||||
{
|
||||
osrm::EngineConfig config;
|
||||
config.storage_config = {base_path};
|
||||
config.use_shared_memory = false;
|
||||
config.algorithm = algorithm;
|
||||
|
||||
return osrm::OSRM{config};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/exception.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
Reference in New Issue
Block a user