From 9e34e5efeae17c2208b33f4d369375ee48eb3bb5 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 24 Jun 2019 15:27:11 +0300 Subject: [PATCH] [routing] Unit tests on yescar and nocar tags. --- generator/generator_tests/osm_type_test.cpp | 54 +++++++++++++++++++++ routing_common/car_model.hpp | 3 ++ 2 files changed, 57 insertions(+) diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index d7ec7f5e42..b3ee0941f3 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -64,6 +64,14 @@ namespace } TEST(params.IsTypeExist(GetType({"psurface", value})), ("Surface:", surface, "Smoothness:", smoothness, "Grade:", grade, "Expected:", value, "Got:", psurface)); } + + void GetFeatureParams(char const * arr[][2], size_t count, FeatureParams & params) + { + OsmElement e; + FillXmlElement(arr, count, &e); + + ftype::GetNameAndType(&e, params); + } } // namespace UNIT_CLASS_TEST(TestWithClassificator, OsmType_SkipDummy) @@ -627,6 +635,52 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Ferry) TEST(params.IsTypeExist(type), ()); } +UNIT_CLASS_TEST(TestWithClassificator, OsmType_YesCarNoCar) +{ + routing::CarModel const & carModel = routing::CarModel::AllLimitsInstance(); + + { + char const* arr[][2] = { + {"highway", "secondary"}, + }; + + FeatureParams params; + GetFeatureParams(arr, ARRAY_SIZE(arr), params); + + TEST_EQUAL(params.m_types.size(), 1, (params)); + TEST(!params.IsTypeExist(carModel.GetNoCarTypeForTesting()), ()); + TEST(!params.IsTypeExist(carModel.GetYesCarTypeForTesting()), ()); + } + + { + char const* arr[][2] = { + {"highway", "cycleway"}, + {"motorcar", "yes"}, + }; + + FeatureParams params; + GetFeatureParams(arr, ARRAY_SIZE(arr), params); + + TEST_EQUAL(params.m_types.size(), 2, (params)); + TEST(!params.IsTypeExist(carModel.GetNoCarTypeForTesting()), ()); + TEST(params.IsTypeExist(carModel.GetYesCarTypeForTesting()), ()); + } + + { + char const* arr[][2] = { + {"highway", "secondary"}, + {"motor_vehicle", "no"}, + }; + + FeatureParams params; + GetFeatureParams(arr, ARRAY_SIZE(arr), params); + + TEST_EQUAL(params.m_types.size(), 2, (params)); + TEST(params.IsTypeExist(carModel.GetNoCarTypeForTesting()), ()); + TEST(!params.IsTypeExist(carModel.GetYesCarTypeForTesting()), ()); + } +} + UNIT_CLASS_TEST(TestWithClassificator, OsmType_Boundary) { char const * arr[][2] = { diff --git a/routing_common/car_model.hpp b/routing_common/car_model.hpp index ba0a307b0f..183ad8a431 100644 --- a/routing_common/car_model.hpp +++ b/routing_common/car_model.hpp @@ -21,6 +21,9 @@ public: static std::vector const & GetAdditionalTags(); static VehicleModel::SurfaceInitList const & GetSurfaces(); + uint32_t GetNoCarTypeForTesting() const { return m_noCarType; } + uint32_t GetYesCarTypeForTesting() const { return m_yesCarType; } + protected: RoadAvailability GetRoadAvailability(feature::TypesHolder const & types) const override;