diff --git a/indexer/categories_holder.cpp b/indexer/categories_holder.cpp index cac2e9e7fe..f677a57d92 100644 --- a/indexer/categories_holder.cpp +++ b/indexer/categories_holder.cpp @@ -27,7 +27,7 @@ int8_t const CategoriesHolder::kUnsupportedLocaleCode = -1; // translation to categories.txt. When editing, keep in mind to check // CategoriesHolder::MapLocaleToInteger() and // CategoriesHolder::MapIntegerToLocale() as their implementations -// highly depend on the contents of the variable. +// strongly depend on the contents of the variable. vector const CategoriesHolder::kLocaleMapping = {{"en", 1}, {"ru", 2}, {"uk", 3}, diff --git a/indexer/categories_holder.hpp b/indexer/categories_holder.hpp index 3719fd7fbc..948f58894c 100644 --- a/indexer/categories_holder.hpp +++ b/indexer/categories_holder.hpp @@ -6,6 +6,7 @@ #include "std/shared_ptr.hpp" #include "std/string.hpp" #include "std/unique_ptr.hpp" +#include "std/unordered_map.hpp" #include "std/vector.hpp" @@ -129,7 +130,7 @@ public: } // Converts any language |locale| from UI to the corresponding - // internal integer code + // internal integer code. static int8_t MapLocaleToInteger(string const & locale); // Returns corresponding string representation for an internal diff --git a/indexer/indexer_tests/categories_test.cpp b/indexer/indexer_tests/categories_test.cpp index 141a05a152..8152110ca4 100644 --- a/indexer/indexer_tests/categories_test.cpp +++ b/indexer/indexer_tests/categories_test.cpp @@ -107,6 +107,18 @@ UNIT_TEST(LoadCategories) TEST_EQUAL(count, 3, ()); } +UNIT_TEST(CategoriesHolder_Smoke) +{ + auto const & mappings = CategoriesHolder::kLocaleMapping; + for (size_t i = 0; i < mappings.size(); ++i) + { + auto const & mapping = mappings[i]; + TEST_EQUAL(i + 1, mapping.m_code, ()); + TEST_EQUAL(i + 1, CategoriesHolder::MapLocaleToInteger(mapping.m_name), ()); + TEST_EQUAL(CategoriesHolder::MapIntegerToLocale(i + 1), mapping.m_name, ()); + } +} + UNIT_TEST(CategoriesIndex_Smoke) { classificator::Load(); diff --git a/map/framework.hpp b/map/framework.hpp index 50982d0f32..98774d76f3 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -120,8 +120,8 @@ protected: model::FeaturesFetcher m_model; - // The order matters here: DisplayedCategories may be used only when - // classificator is loaded (by |m_model|). + // The order matters here: DisplayedCategories may be used only + // after classificator is loaded by |m_model|. unique_ptr m_displayedCategories; // The order matters here: storage::CountryInfoGetter and diff --git a/search/displayed_categories.hpp b/search/displayed_categories.hpp index 781cb2a4d9..8f3cbd614c 100644 --- a/search/displayed_categories.hpp +++ b/search/displayed_categories.hpp @@ -18,6 +18,8 @@ public: // of resources ids. static vector const & GetKeys(); + // Calls |fn| on each pair (synonym name, synonym locale) for the + // |key|. template void ForEachSynonym(string const & key, Fn && fn) const {