Route absent country list double entry fix.

This commit is contained in:
Lev Dragunov 2015-07-09 14:22:42 +03:00 committed by Alex Zolotarev
parent 3eeda44d2c
commit 31ffea5972
3 changed files with 27 additions and 3 deletions

View file

@ -5,6 +5,7 @@
#include "geometry/polyline2d.hpp"
#include "std/vector.hpp"
#include "std/set.hpp"
#include "std/string.hpp"
@ -99,10 +100,10 @@ public:
bool IsCurrentOnEnd() const;
/// Add country name if we have no country filename to make route
void AddAbsentCountry(string const & name) {m_absentCountries.push_back(name);}
void AddAbsentCountry(string const & name) { m_absentCountries.insert(name); }
/// Get absent file list of a routing files for shortest path finding
vector<string> const & GetAbsentCountries() const {return m_absentCountries;}
set<string> const & GetAbsentCountries() const { return m_absentCountries; }
private:
/// @param[in] predictDistance Predict distance from previous FindProjection call (meters).
@ -124,7 +125,7 @@ private:
m2::PolylineD m_poly;
string m_name;
vector<string> m_absentCountries;
set<string> m_absentCountries;
/// Accumulated cache of segments length in meters.
vector<double> m_segDistance;

View file

@ -0,0 +1,22 @@
#include "testing/testing.hpp"
#include "routing/route.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
using namespace routing;
UNIT_TEST(AddAdsentCountryToRouteTest)
{
Route route("TestRouter");
route.AddAbsentCountry("A");
route.AddAbsentCountry("A");
route.AddAbsentCountry("B");
route.AddAbsentCountry("C");
route.AddAbsentCountry("B");
set<string> const & absent = route.GetAbsentCountries();
TEST(absent.find("A") != absent.end(), ());
TEST(absent.find("B") != absent.end(), ());
TEST(absent.find("C") != absent.end(), ());
}

View file

@ -31,6 +31,7 @@ SOURCES += \
osrm_router_test.cpp \
road_graph_builder.cpp \
road_graph_nearest_edges_test.cpp \
route_tests.cpp \
turns_generator_test.cpp \
turns_sound_test.cpp \
vehicle_model_test.cpp \