diff options
author | vng <viktor.govako@gmail.com> | 2014-11-04 19:07:39 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:32:15 +0300 |
commit | 39818e3e081419e1307017bf90acc9a886eb64b8 (patch) | |
tree | 3f91418e9da94e0b781bb7c89a4aadddc57c9f37 /map/mwm_tests | |
parent | d9010aaa5936878077242bc75d12c98d81754def (diff) |
[tests] Check that feature has nonempty geometry if it’s stored in geometry index for the particular scale.
Diffstat (limited to 'map/mwm_tests')
-rw-r--r-- | map/mwm_tests/mwm_index_test.cpp | 67 | ||||
-rw-r--r-- | map/mwm_tests/mwm_tests.pro | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/map/mwm_tests/mwm_index_test.cpp b/map/mwm_tests/mwm_index_test.cpp new file mode 100644 index 0000000000..732b803ed9 --- /dev/null +++ b/map/mwm_tests/mwm_index_test.cpp @@ -0,0 +1,67 @@ +#include "../../testing/testing.hpp" + +#include "../../map/feature_vec_model.hpp" + +#include "../../indexer/scales.hpp" +#include "../../indexer/classificator_loader.hpp" + + +namespace +{ + +class CheckNonEmptyGeometry +{ + int m_scale; +public: + vector<FeatureID> m_ids; + + void operator() (FeatureID const & id) + { + m_ids.push_back(id); + } + + void operator() (FeatureType const & ft) + { + bool res = false; + ft.ForEachPoint([&res] (CoordPointT const &) { res = true; }, m_scale); + ft.ForEachTriangle([&res] (m2::PointD const &, m2::PointD const &, m2::PointD const &) { res = true; }, m_scale); + + TEST(res, (ft, "Scale =", m_scale)); + } + + void SetScale(int scale) + { + m_ids.clear(); + m_scale = scale; + } +}; + +bool RunTest(string const & fileName, int lowS, int highS) +{ + model::FeaturesFetcher src; + if (src.AddMap(fileName) == -1) + return false; + + CheckNonEmptyGeometry doCheck; + for (int scale = lowS; scale <= highS; ++scale) + { + doCheck.SetScale(scale); + src.ForEachFeatureID(MercatorBounds::FullRect(), doCheck, scale); + src.ReadFeatures(doCheck, doCheck.m_ids); + } + + return true; +} + +} + +UNIT_TEST(ForEachFeatureID_Test) +{ + classificator::Load(); + + /// @todo Uncomment World* checking after next map data update. + //TEST(RunTest("World.mwm", 0, scales::GetUpperWorldScale()), ()); + //TEST(RunTest("WorldCoasts.mwm", 0, scales::GetUpperWorldScale()), ()); + //TEST(RunTest("Belarus.mwm", scales::GetUpperWorldScale() + 1, scales::GetUpperStyleScale()), ()); + TEST(RunTest("minsk-pass.mwm", scales::GetUpperWorldScale() + 1, scales::GetUpperStyleScale()), ()); +} diff --git a/map/mwm_tests/mwm_tests.pro b/map/mwm_tests/mwm_tests.pro index 186bc8e195..38731c7fc0 100644 --- a/map/mwm_tests/mwm_tests.pro +++ b/map/mwm_tests/mwm_tests.pro @@ -23,3 +23,4 @@ SOURCES += \ ../../testing/testingmain.cpp \ mwm_foreach_test.cpp \ multithread_mwm_test.cpp \ + mwm_index_test.cpp \ |