Tests for config level constraints; table failing: see #2100
This commit is contained in:
		
							parent
							
								
									1d11701034
								
							
						
					
					
						commit
						fea6c2731a
					
				
							
								
								
									
										20
									
								
								unit_tests/library/fixture.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								unit_tests/library/fixture.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					#ifndef OSRM_LIBRARY_TEST_FIXTURE
 | 
				
			||||||
 | 
					#define OSRM_LIBRARY_TEST_FIXTURE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "osrm/engine_config.hpp"
 | 
				
			||||||
 | 
					#include "osrm/osrm.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 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 get_osrm(const std::string &base_path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    osrm::EngineConfig config{base_path};
 | 
				
			||||||
 | 
					    config.use_shared_memory = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return osrm::OSRM{config};
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										135
									
								
								unit_tests/library/limits.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								unit_tests/library/limits.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "osrm/trip_parameters.hpp"
 | 
				
			||||||
 | 
					#include "osrm/route_parameters.hpp"
 | 
				
			||||||
 | 
					#include "osrm/table_parameters.hpp"
 | 
				
			||||||
 | 
					#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(limits)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOST_AUTO_TEST_CASE(test_trip_limits)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const auto args = get_args();
 | 
				
			||||||
 | 
					    BOOST_REQUIRE_EQUAL(args.size(), 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    using namespace osrm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EngineConfig config{args[0]};
 | 
				
			||||||
 | 
					    config.use_shared_memory = false;
 | 
				
			||||||
 | 
					    config.max_locations_trip = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OSRM osrm{config};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TripParameters params;
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    json::Object result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const auto rc = osrm.Trip(params, result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BOOST_CHECK(rc == Status::Error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Make sure we're not accidentally hitting a guard code path before
 | 
				
			||||||
 | 
					    const auto code = result.values["code"].get<json::String>().value;
 | 
				
			||||||
 | 
					    BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOST_AUTO_TEST_CASE(test_route_limits)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const auto args = get_args();
 | 
				
			||||||
 | 
					    BOOST_REQUIRE_EQUAL(args.size(), 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    using namespace osrm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EngineConfig config{args[0]};
 | 
				
			||||||
 | 
					    config.use_shared_memory = false;
 | 
				
			||||||
 | 
					    config.max_locations_viaroute = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OSRM osrm{config};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RouteParameters params;
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    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::Error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Make sure we're not accidentally hitting a guard code path before
 | 
				
			||||||
 | 
					    const auto code = result.values["code"].get<json::String>().value;
 | 
				
			||||||
 | 
					    BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOST_AUTO_TEST_CASE(test_table_limits)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const auto args = get_args();
 | 
				
			||||||
 | 
					    BOOST_REQUIRE_EQUAL(args.size(), 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    using namespace osrm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EngineConfig config{args[0]};
 | 
				
			||||||
 | 
					    config.use_shared_memory = false;
 | 
				
			||||||
 | 
					    config.max_locations_distance_table = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OSRM osrm{config};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TableParameters params;
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    json::Object result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const auto rc = osrm.Table(params, result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BOOST_CHECK(rc == Status::Error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Make sure we're not accidentally hitting a guard code path before
 | 
				
			||||||
 | 
					    const auto code = result.values["code"].get<json::String>().value;
 | 
				
			||||||
 | 
					    BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOST_AUTO_TEST_CASE(test_match_limits)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const auto args = get_args();
 | 
				
			||||||
 | 
					    BOOST_REQUIRE_EQUAL(args.size(), 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    using namespace osrm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EngineConfig config{args[0]};
 | 
				
			||||||
 | 
					    config.use_shared_memory = false;
 | 
				
			||||||
 | 
					    config.max_locations_map_matching = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OSRM osrm{config};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MatchParameters params;
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    json::Object result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const auto rc = osrm.Match(params, result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BOOST_CHECK(rc == Status::Error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Make sure we're not accidentally hitting a guard code path before
 | 
				
			||||||
 | 
					    const auto code = result.values["code"].get<json::String>().value;
 | 
				
			||||||
 | 
					    BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOST_AUTO_TEST_SUITE_END()
 | 
				
			||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/match_parameters.hpp"
 | 
					#include "osrm/match_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/nearest_parameters.hpp"
 | 
					#include "osrm/nearest_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,8 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					#include "fixture.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/route_parameters.hpp"
 | 
					#include "osrm/route_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -16,15 +17,10 @@ BOOST_AUTO_TEST_SUITE(route)
 | 
				
			|||||||
BOOST_AUTO_TEST_CASE(test_route)
 | 
					BOOST_AUTO_TEST_CASE(test_route)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const auto args = get_args();
 | 
					    const auto args = get_args();
 | 
				
			||||||
    BOOST_REQUIRE_EQUAL(args.size(), 1);
 | 
					    auto osrm = get_osrm(args.at(0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    using namespace osrm;
 | 
					    using namespace osrm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EngineConfig config{args[0]};
 | 
					 | 
				
			||||||
    config.use_shared_memory = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    OSRM osrm{config};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RouteParameters params;
 | 
					    RouteParameters params;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
					    params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/table_parameters.hpp"
 | 
					#include "osrm/table_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/tile_parameters.hpp"
 | 
					#include "osrm/tile_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#include <boost/test/unit_test.hpp>
 | 
					#include <boost/test/unit_test.hpp>
 | 
				
			||||||
#include <boost/test/test_case_template.hpp>
 | 
					#include <boost/test/test_case_template.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "args.h"
 | 
					#include "args.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "osrm/trip_parameters.hpp"
 | 
					#include "osrm/trip_parameters.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user