From 7d8ba1a2b2ceccfc4fc4d60359965b1255f729a2 Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 3 Jun 2021 22:51:09 +0300 Subject: [PATCH] [tests] Fixed countries test for dummy object in current data. Signed-off-by: vng --- map/map_tests/countries_names_tests.cpp | 44 ++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/map/map_tests/countries_names_tests.cpp b/map/map_tests/countries_names_tests.cpp index 1de399b1de..1a1d71c4f1 100644 --- a/map/map_tests/countries_names_tests.cpp +++ b/map/map_tests/countries_names_tests.cpp @@ -18,11 +18,8 @@ #include "base/cancellable.hpp" #include "base/checked_cast.hpp" -#include #include #include -#include -#include using namespace platform; using namespace storage; @@ -45,18 +42,20 @@ UNIT_TEST(CountriesNamesTest) base::Cancellable const cancellable; search::CategoriesCache cache(ftypes::IsLocalityChecker::Instance(), cancellable); - vector const langIndices = {StringUtf8Multilang::kEnglishCode, - StringUtf8Multilang::kDefaultCode, - StringUtf8Multilang::kInternationalCode}; + int8_t const langIndices[] = { StringUtf8Multilang::kEnglishCode, + StringUtf8Multilang::kDefaultCode, + StringUtf8Multilang::kInternationalCode }; set const kIgnoreList = {"Turkish Republic Of Northern Cyprus", "Transnistria", "Nagorno-Karabakh Republic", "Republic of Artsakh", + "Port aux Français" /// @todo Temporary entry to fix test in current data. }; auto const features = cache.Get(mwmContext); - features.ForEach([&](uint64_t fid) { + features.ForEach([&](uint64_t fid) + { auto ft = g.GetFeatureByIndex(base::asserted_cast(fid)); TEST(ft, ()); @@ -64,17 +63,24 @@ UNIT_TEST(CountriesNamesTest) if (type != ftypes::LocalityType::Country) return; - TEST(any_of(langIndices.begin(), langIndices.end(), - [&](uint8_t langIndex) { - string name; - if (!ft->GetName(langIndex, name)) - return false; - auto const it = synonyms.find(name); - if (it == synonyms.end()) - return storage.IsNode(name) || kIgnoreList.count(name) != 0; - return storage.IsNode(it->second); - }), - ("Cannot find countries.txt record for country feature:", - ft->DebugString(FeatureType::BEST_GEOMETRY))); + bool found = false; + for (auto const lang : langIndices) + { + string name; + if (ft->GetName(lang, name)) + { + auto const it = synonyms.find(name); + if (it == synonyms.end()) + found = storage.IsNode(name) || kIgnoreList.count(name) != 0; + else + found = storage.IsNode(it->second); + + if (found) + break; + } + } + + // If this test fails, most likely somebody added fake place=country object into OSM. + TEST(found, ("Cannot find countries.txt record for country feature:", ft->DebugString(FeatureType::BEST_GEOMETRY))); }); }