diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 94b89613de..964508cd85 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -220,6 +220,12 @@ public: } } + template + void ForEachTriangle(FunctorT f, int scale) const + { + ForEachTriangleRef(f, scale); + } + template void ForEachTriangleExRef(FunctorT & f, int scale) const { diff --git a/map/map_tests/feature_processor_test.cpp b/map/map_tests/feature_processor_test.cpp index 050c4bdb50..269e2b20c7 100644 --- a/map/map_tests/feature_processor_test.cpp +++ b/map/map_tests/feature_processor_test.cpp @@ -1,15 +1,17 @@ -#include "../../base/SRC_FIRST.hpp" - #include "../../testing/testing.hpp" -#include "../../geometry/screenbase.hpp" -#include "../../base/logging.hpp" #include "../feature_processor.hpp" #include "../geometry_processors.hpp" +#include "../../geometry/screenbase.hpp" + +#include "../../base/logging.hpp" + + + UNIT_TEST(PathPoints_ClipAsIntervals) { - m2::PointD pts[10] = + m2::PointD pts[] = { m2::PointD(0, 0), m2::PointD(10, 0), @@ -42,14 +44,13 @@ UNIT_TEST(PathPoints_ClipAsIntervals) functor_t fun(p); - for (unsigned i = 0; i < 10; ++i) + for (size_t i = 0; i < ARRAY_SIZE(pts); ++i) fun(pts[i]); - fun.IsExist(); + TEST(fun.IsExist(), ()); - double res [2] = {5, 45}; - - TEST(std::equal(intervals.begin(), intervals.end(), res), ()); + double res[] = { 5, 45 }; + TEST(equal(intervals.begin(), intervals.end(), res), ()); typedef gp::filter_screenpts_adapter cut_functor_t; @@ -61,7 +62,7 @@ UNIT_TEST(PathPoints_ClipAsIntervals) cut_functor_t cut_fun(cp); - for (unsigned i = 0; i < ARRAY_SIZE(pts); ++i) + for (size_t i = 0; i < ARRAY_SIZE(pts); ++i) cut_fun(CoordPointT(pts[i].x, pts[i].y)); m2::PointD res1[] = { @@ -73,12 +74,12 @@ UNIT_TEST(PathPoints_ClipAsIntervals) m2::PointD(25, 10) }; - TEST(std::equal(res1, res1 + ARRAY_SIZE(res1), cut_fun.m_points.back().m_path.begin()), ()); + TEST(equal(res1, res1 + ARRAY_SIZE(res1), cut_fun.m_points.back().m_path.begin()), ()); } UNIT_TEST(PathPoints_DeadZoneClipping) { - m2::PointD pts[10] = + m2::PointD pts[] = { m2::PointD(0, 0), m2::PointD(10, 0), @@ -104,14 +105,10 @@ UNIT_TEST(PathPoints_DeadZoneClipping) p.m_rect = &r; gp::path_points fun(p); - for (unsigned i = 0; i < 10; ++i) + for (size_t i = 0; i < ARRAY_SIZE(pts); ++i) fun(pts[i]); - fun.IsExist(); + TEST(fun.IsExist(), ()); -// int pathCount = fun.m_points.size(); - - di::PathInfo pi = fun.m_points.front(); - vector pts1 = fun.m_points.front().m_path; -// LOG(LINFO, (pts1)); + //LOG(LINFO, (fun.m_points.front().m_path)); } 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 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 \ diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index e9a9b1b138..61b6aba122 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -33,11 +33,7 @@ UNIT_TEST(LocalityFinder) { Index index; m2::RectD rect; - if (!index.Add("World.mwm", rect)) - { - LOG(LWARNING, ("MWM file not found")); - return; - } + TEST(index.Add("World.mwm", rect), ()); search::LocalityFinder finder(&index); finder.SetLanguage(StringUtf8Multilang::GetLangIndex("en"));