diff options
author | vng <viktor.govako@gmail.com> | 2011-11-30 20:59:16 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:29:20 +0300 |
commit | 61d5fd30b02167af6fa6caeb50aa065f617d8e37 (patch) | |
tree | 6ad13bd1ff5fa8648ae5dd50355704c0e39f9ef5 /generator/generator_tests/osm_type_test.cpp | |
parent | cbebc74dab177cc42b4f94269da46e96979909e0 (diff) |
Add test for types mapping.
Diffstat (limited to 'generator/generator_tests/osm_type_test.cpp')
-rw-r--r-- | generator/generator_tests/osm_type_test.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index e4036bf4b3..b258120fc1 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -7,6 +7,8 @@ #include "../../indexer/classificator.hpp" #include "../../indexer/classificator_loader.hpp" +#include "../../std/iostream.hpp" + namespace { @@ -51,3 +53,60 @@ UNIT_TEST(OsmType_SkipDummy) TEST_EQUAL ( params.m_Types.size(), 1, () ); TEST_EQUAL ( params.m_Types[0], GetType(arr[1]), () ); } + + +namespace +{ + struct DoDumpType + { + void operator() (ClassifObject const * p) + { + cout << p->GetName() << "-"; + } + }; + + template <class ToDo> + void ForEachType(uint32_t type, ToDo toDo) + { + ClassifObject const * p = classif().GetRoot(); + uint8_t i = 0; + uint8_t v; + + // get objects route in hierarchy for type + while (ftype::GetValue(type, i, v)) + { + p = p->GetObject(v); + toDo(p); + ++i; + } + } + + void DumpTypes(vector<uint32_t> const & v) + { + for (size_t i = 0; i < v.size(); ++i) + { + ForEachType(v[i], DoDumpType()); + cout << endl; + } + } +} + +UNIT_TEST(OsmType_Check1) +{ + classificator::Load(); + + char const * arr[][2] = { + { "highway", "primary" }, + { "motorroad", "yes" }, + { "name", "Каширское шоссе" }, + { "oneway", "yes" } + }; + + XMLElement e; + FillXmlElement(arr, ARRAY_SIZE(arr), &e); + + FeatureParams params; + ftype::GetNameAndType(&e, params); + + DumpTypes(params.m_Types); +} |