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:
-rw-r--r--indexer/indexer_tests/CMakeLists.txt1
-rw-r--r--indexer/indexer_tests/classificator_tests.cpp96
-rw-r--r--map/style_tests/classificator_tests.cpp17
-rw-r--r--xcode/indexer/indexer.xcodeproj/project.pbxproj4
4 files changed, 101 insertions, 17 deletions
diff --git a/indexer/indexer_tests/CMakeLists.txt b/indexer/indexer_tests/CMakeLists.txt
index 650b64dc7a..e103677009 100644
--- a/indexer/indexer_tests/CMakeLists.txt
+++ b/indexer/indexer_tests/CMakeLists.txt
@@ -10,6 +10,7 @@ set(
centers_table_test.cpp
checker_test.cpp
cities_boundaries_serdes_tests.cpp
+ classificator_tests.cpp
data_source_test.cpp
drules_selector_parser_test.cpp
editable_map_object_test.cpp
diff --git a/indexer/indexer_tests/classificator_tests.cpp b/indexer/indexer_tests/classificator_tests.cpp
new file mode 100644
index 0000000000..325b1e5aff
--- /dev/null
+++ b/indexer/indexer_tests/classificator_tests.cpp
@@ -0,0 +1,96 @@
+#include "testing/testing.hpp"
+
+#include "indexer/classificator.hpp"
+#include "indexer/classificator_loader.hpp"
+
+#include <algorithm>
+#include <cstdint>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+namespace
+{
+class ClassificatorTest
+{
+public:
+ ClassificatorTest()
+ {
+ classificator::Load();
+ }
+
+ ~ClassificatorTest() = default;
+};
+} // namespace
+
+UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetType)
+{
+ Classificator const & c = classif();
+
+ uint32_t const type1 = c.GetTypeByPath({"natural", "coastline"});
+ TEST_NOT_EQUAL(0, type1, ());
+ TEST(c.IsTypeValid(type1), ());
+ TEST_EQUAL(type1, c.GetTypeByReadableObjectName("natural-coastline"), ());
+
+ uint32_t const type2 = c.GetTypeByPath({"amenity", "parking", "private"});
+ TEST_NOT_EQUAL(0, type2, ());
+ TEST(c.IsTypeValid(type2), ());
+ TEST_EQUAL(type2, c.GetTypeByReadableObjectName("amenity-parking-private"), ());
+
+ TEST_EQUAL(0, c.GetTypeByPathSafe({"nonexisting", "type"}), ());
+ TEST_EQUAL(0, c.GetTypeByReadableObjectName("nonexisting-type"), ());
+ TEST(!c.IsTypeValid(0), ());
+}
+
+UNIT_CLASS_TEST(ClassificatorTest, Classificator_CoastlineType)
+{
+ Classificator const & c = classif();
+
+ uint32_t const type = c.GetTypeByPath({"natural", "coastline"});
+ TEST(c.IsTypeValid(type), ());
+ TEST_EQUAL(type, c.GetCoastType(), ());
+}
+
+UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetIndex)
+{
+ Classificator const & c = classif();
+
+ uint32_t const type = c.GetTypeByPath({"railway", "station", "subway"});
+ uint32_t const index = c.GetIndexForType(type);
+ TEST(c.IsTypeValid(type), ());
+ TEST_EQUAL(type, c.GetTypeForIndex(index), ());
+}
+
+UNIT_CLASS_TEST(ClassificatorTest, Classificator_Subtree)
+{
+ Classificator const & c = classif();
+
+ uint32_t const cityType = c.GetTypeByPath({"place", "city"});
+
+ vector<vector<string>> const expectedPaths = {
+ {"place", "city"},
+ {"place", "city", "capital"},
+ {"place", "city", "capital", "2"},
+ {"place", "city", "capital", "3"},
+ {"place", "city", "capital", "4"},
+ {"place", "city", "capital", "5"},
+ {"place", "city", "capital", "6"},
+ {"place", "city", "capital", "7"},
+ {"place", "city", "capital", "8"},
+ {"place", "city", "capital", "9"},
+ {"place", "city", "capital", "10"},
+ {"place", "city", "capital", "11"},
+ };
+
+ vector<uint32_t> expectedTypes;
+ for (auto const & path : expectedPaths)
+ expectedTypes.push_back(classif().GetTypeByPath(path));
+ sort(expectedTypes.begin(), expectedTypes.end());
+
+ vector<uint32_t> subtreeTypes;
+ c.ForEachInSubtree([&subtreeTypes](uint32_t type) { subtreeTypes.push_back(type); }, cityType);
+ sort(subtreeTypes.begin(), subtreeTypes.end());
+
+ TEST_EQUAL(expectedTypes, subtreeTypes, ());
+}
diff --git a/map/style_tests/classificator_tests.cpp b/map/style_tests/classificator_tests.cpp
index c0a875768a..f930e887d6 100644
--- a/map/style_tests/classificator_tests.cpp
+++ b/map/style_tests/classificator_tests.cpp
@@ -285,20 +285,3 @@ UNIT_TEST(Classificator_PoiPriority)
CheckPriority(types, {2, 5}, drule::symbol);
}
}
-
-UNIT_TEST(Classificator_GetType)
-{
- classificator::Load();
- Classificator const & c = classif();
-
- uint32_t const type1 = c.GetTypeByPath({"natural", "coastline"});
- TEST_NOT_EQUAL(0, type1, ());
- TEST_EQUAL(type1, c.GetTypeByReadableObjectName("natural-coastline"), ());
-
- uint32_t const type2 = c.GetTypeByPath({"amenity", "parking", "private"});
- TEST_NOT_EQUAL(0, type2, ());
- TEST_EQUAL(type2, c.GetTypeByReadableObjectName("amenity-parking-private"), ());
-
- TEST_EQUAL(0, c.GetTypeByPathSafe({"nonexisting", "type"}), ());
- TEST_EQUAL(0, c.GetTypeByReadableObjectName("nonexisting-type"), ());
-}
diff --git a/xcode/indexer/indexer.xcodeproj/project.pbxproj b/xcode/indexer/indexer.xcodeproj/project.pbxproj
index ed69e4977f..d35bf88309 100644
--- a/xcode/indexer/indexer.xcodeproj/project.pbxproj
+++ b/xcode/indexer/indexer.xcodeproj/project.pbxproj
@@ -73,6 +73,7 @@
4099F64A1FC7142A002A7B05 /* fake_feature_ids.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4099F6481FC7142A002A7B05 /* fake_feature_ids.hpp */; };
40A1C30A202B321000F71672 /* locality_index_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40A1C309202B321000F71672 /* locality_index_test.cpp */; };
40C3C091205BF9F400CED188 /* bounds.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 40C3C090205BF9F400CED188 /* bounds.hpp */; };
+ 40DF582D2174979200E4E0FC /* classificator_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40DF582C2174979200E4E0FC /* classificator_tests.cpp */; };
456B3FB41EDEEB65009B3D1F /* scales_patch.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 456B3FB31EDEEB65009B3D1F /* scales_patch.hpp */; };
456E1B181F90E5B7009C32E1 /* cities_boundaries_serdes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 456E1B141F90E5B6009C32E1 /* cities_boundaries_serdes.hpp */; };
456E1B191F90E5B7009C32E1 /* ftypes_sponsored.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 456E1B151F90E5B6009C32E1 /* ftypes_sponsored.cpp */; };
@@ -293,6 +294,7 @@
4099F6481FC7142A002A7B05 /* fake_feature_ids.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = fake_feature_ids.hpp; sourceTree = "<group>"; };
40A1C309202B321000F71672 /* locality_index_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = locality_index_test.cpp; sourceTree = "<group>"; };
40C3C090205BF9F400CED188 /* bounds.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bounds.hpp; sourceTree = "<group>"; };
+ 40DF582C2174979200E4E0FC /* classificator_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classificator_tests.cpp; sourceTree = "<group>"; };
456B3FB31EDEEB65009B3D1F /* scales_patch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = scales_patch.hpp; sourceTree = "<group>"; };
456E1B141F90E5B6009C32E1 /* cities_boundaries_serdes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cities_boundaries_serdes.hpp; sourceTree = "<group>"; };
456E1B151F90E5B6009C32E1 /* ftypes_sponsored.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ftypes_sponsored.cpp; sourceTree = "<group>"; };
@@ -564,6 +566,7 @@
3D452AF91EE6D9F5009EAB9B /* centers_table_test.cpp */,
670C60FC1AB065B100C38A8C /* checker_test.cpp */,
39F376BE207D32410058E8E0 /* cities_boundaries_serdes_tests.cpp */,
+ 40DF582C2174979200E4E0FC /* classificator_tests.cpp */,
56C74C271C749E8100B71B9F /* drules_selector_parser_test.cpp */,
3D489BA71D3D1F8A0052AA38 /* editable_map_object_test.cpp */,
56C74C281C749E8100B71B9F /* feature_metadata_test.cpp */,
@@ -993,6 +996,7 @@
56C74C1C1C749E4700B71B9F /* categories_holder_loader.cpp in Sources */,
3D74EF241F8F559D0081202C /* ugc_types_test.cpp in Sources */,
406B37F4207FBABB000F3648 /* borders.cpp in Sources */,
+ 40DF582D2174979200E4E0FC /* classificator_tests.cpp in Sources */,
40A1C30A202B321000F71672 /* locality_index_test.cpp in Sources */,
6753410D1A3F540F00A0A8C3 /* drawing_rules.cpp in Sources */,
675341301A3F540F00A0A8C3 /* data_source.cpp in Sources */,