Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2017-02-08 16:21:10 +0300
committerMaxim Pimenov <m@maps.me>2017-02-10 13:40:05 +0300
commitb95690dcd7927babf961b48ec096b0712590ba43 (patch)
treeaa5cb35f69cf0ae6d9dd1f34dbe4746e45bcafcf /indexer/indexer_tests
parent5562457ce86f9dac17558ddbcdf3c6dfab6e61ba (diff)
[indexer] Changed a map to a trie in CategoriesHolder.
Also, minor style refactorings.
Diffstat (limited to 'indexer/indexer_tests')
-rw-r--r--indexer/indexer_tests/categories_test.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/indexer/indexer_tests/categories_test.cpp b/indexer/indexer_tests/categories_test.cpp
index bea439e730..5bc2698013 100644
--- a/indexer/indexer_tests/categories_test.cpp
+++ b/indexer/indexer_tests/categories_test.cpp
@@ -20,6 +20,7 @@
#include "std/transform_iterator.hpp"
#include "base/stl_helpers.hpp"
+#include "base/string_utils.hpp"
using namespace indexer;
@@ -222,6 +223,48 @@ UNIT_TEST(CategoriesHolder_DisplayedName)
});
}
+UNIT_TEST(CategoriesHolder_ForEach)
+{
+ char const kCategories[] =
+ "amenity-bar\n"
+ "en:abc|ddd-eee\n"
+ "\n"
+ "amenity-pub\n"
+ "en:ddd\n"
+ "\n"
+ "amenity-cafe\n"
+ "en:abc eee\n"
+ "\n"
+ "amenity-restaurant\n"
+ "en:ddd|eee\n"
+ "\n"
+ "";
+
+ classificator::Load();
+ CategoriesHolder holder(make_unique<MemReader>(kCategories, ARRAY_SIZE(kCategories) - 1));
+
+ {
+ uint32_t counter = 0;
+ holder.ForEachTypeByName(CategoriesHolder::kEnglishCode, strings::MakeUniString("abc"),
+ [&](uint32_t /* type */) { ++counter; });
+ TEST_EQUAL(counter, 2, ());
+ }
+
+ {
+ uint32_t counter = 0;
+ holder.ForEachTypeByName(CategoriesHolder::kEnglishCode, strings::MakeUniString("ddd"),
+ [&](uint32_t /* type */) { ++counter; });
+ TEST_EQUAL(counter, 3, ());
+ }
+
+ {
+ uint32_t counter = 0;
+ holder.ForEachTypeByName(CategoriesHolder::kEnglishCode, strings::MakeUniString("eee"),
+ [&](uint32_t /* type */) { ++counter; });
+ TEST_EQUAL(counter, 3, ());
+ }
+}
+
UNIT_TEST(CategoriesIndex_Smoke)
{
classificator::Load();