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:
authortatiana-yan <tatiana.kondakova@gmail.com>2018-10-15 18:18:16 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2018-10-16 15:03:27 +0300
commit61dad68a7314deebcf2dabd934b7eacfc3696bf7 (patch)
tree5653d47389903e0ff9db56722c062e581cb510c2
parente5cc7611b02f38e0183aa14f7048934c69e12153 (diff)
[test] Fix classificator load in tests.
-rw-r--r--generator/generator_tests/feature_builder_test.cpp26
-rw-r--r--generator/generator_tests/osm_type_test.cpp96
-rw-r--r--indexer/indexer_tests/classificator_tests.cpp26
-rw-r--r--routing/routing_integration_tests/get_altitude_test.cpp5
4 files changed, 65 insertions, 88 deletions
diff --git a/generator/generator_tests/feature_builder_test.cpp b/generator/generator_tests/feature_builder_test.cpp
index bbc5b38544..89c3f0f76d 100644
--- a/generator/generator_tests/feature_builder_test.cpp
+++ b/generator/generator_tests/feature_builder_test.cpp
@@ -3,6 +3,7 @@
#include "types_helper.hpp"
#include "generator/feature_builder.hpp"
+#include "generator/generator_tests_support/test_with_classificator.hpp"
#include "generator/osm2type.hpp"
#include "indexer/classificator_loader.hpp"
@@ -10,13 +11,11 @@
#include "base/geo_object_id.hpp"
+using namespace generator::tests_support;
using namespace tests;
-
-UNIT_TEST(FBuilder_ManyTypes)
+UNIT_CLASS_TEST(TestWithClassificator, FBuilder_ManyTypes)
{
- classificator::Load();
-
FeatureBuilder1 fb1;
FeatureParams params;
@@ -59,7 +58,7 @@ UNIT_TEST(FBuilder_ManyTypes)
TEST_EQUAL(fb2.GetTypesCount(), 6, ());
}
-UNIT_TEST(FBuilder_LineTypes)
+UNIT_CLASS_TEST(TestWithClassificator, FBuilder_LineTypes)
{
FeatureBuilder1 fb1;
FeatureParams params;
@@ -95,10 +94,8 @@ UNIT_TEST(FBuilder_LineTypes)
TEST_EQUAL(fb2.GetTypesCount(), 5, ());
}
-UNIT_TEST(FBuilder_Waterfall)
+UNIT_CLASS_TEST(TestWithClassificator, FBuilder_Waterfall)
{
- classificator::Load();
-
FeatureBuilder1 fb1;
FeatureParams params;
@@ -124,7 +121,7 @@ UNIT_TEST(FBuilder_Waterfall)
TEST_EQUAL(fb2.GetTypesCount(), 1, ());
}
-UNIT_TEST(FBbuilder_GetMostGeneralOsmId)
+UNIT_CLASS_TEST(TestWithClassificator, FBbuilder_GetMostGeneralOsmId)
{
FeatureBuilder1 fb;
@@ -141,9 +138,8 @@ UNIT_TEST(FBbuilder_GetMostGeneralOsmId)
TEST_EQUAL(fb.GetMostGenericOsmId(), base::MakeOsmRelation(1), ());
}
-UNIT_TEST(FVisibility_RemoveNoDrawableTypes)
+UNIT_CLASS_TEST(TestWithClassificator, FVisibility_RemoveNoDrawableTypes)
{
- classificator::Load();
Classificator const & c = classif();
{
@@ -166,10 +162,8 @@ UNIT_TEST(FVisibility_RemoveNoDrawableTypes)
}
}
-UNIT_TEST(FBuilder_RemoveUselessNames)
+UNIT_CLASS_TEST(TestWithClassificator, FBuilder_RemoveUselessNames)
{
- classificator::Load();
-
FeatureParams params;
char const * arr3[][3] = { { "boundary", "administrative", "2" } };
@@ -199,10 +193,8 @@ UNIT_TEST(FBuilder_RemoveUselessNames)
TEST(fb1.CheckValid(), ());
}
-UNIT_TEST(FeatureParams_Parsing)
+UNIT_CLASS_TEST(TestWithClassificator, FeatureParams_Parsing)
{
- classificator::Load();
-
{
FeatureParams params;
params.AddStreet("Embarcadero\nstreet");
diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp
index ceb29881e5..9c7a96a045 100644
--- a/generator/generator_tests/osm_type_test.cpp
+++ b/generator/generator_tests/osm_type_test.cpp
@@ -1,9 +1,7 @@
#include "testing/testing.hpp"
-#include "types_helper.hpp"
-
-#include "platform/platform.hpp"
-
+#include "generator/generator_tests/types_helper.hpp"
+#include "generator/generator_tests_support/test_with_classificator.hpp"
#include "generator/osm_element.hpp"
#include "generator/osm2type.hpp"
#include "generator/tag_admixer.hpp"
@@ -14,32 +12,15 @@
#include "indexer/classificator.hpp"
#include "indexer/classificator_loader.hpp"
+#include "platform/platform.hpp"
+
#include <iostream>
+#include <string>
+#include <vector>
+using namespace generator::tests_support;
using namespace tests;
-UNIT_TEST(OsmType_SkipDummy)
-{
- classificator::Load();
-
- char const * arr[][2] = {
- { "abutters", "residential" },
- { "highway", "primary" },
- { "osmarender:renderRef", "no" },
- { "ref", "E51" }
- };
-
- OsmElement e;
- FillXmlElement(arr, ARRAY_SIZE(arr), &e);
-
- FeatureParams params;
- ftype::GetNameAndType(&e, params);
-
- TEST_EQUAL ( params.m_types.size(), 1, (params) );
- TEST_EQUAL ( params.m_types[0], GetType(arr[1]), () );
-}
-
-
namespace
{
void DumpTypes(std::vector<uint32_t> const & v)
@@ -83,12 +64,29 @@ namespace
}
TEST(params.IsTypeExist(GetType({"psurface", value})), ("Surface:", surface, "Smoothness:", smoothness, "Grade:", grade, "Expected:", value, "Got:", psurface));
}
-}
+} // namespace
-UNIT_TEST(OsmType_Check)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_SkipDummy)
{
- classificator::Load();
+ char const * arr[][2] = {
+ { "abutters", "residential" },
+ { "highway", "primary" },
+ { "osmarender:renderRef", "no" },
+ { "ref", "E51" }
+ };
+ OsmElement e;
+ FillXmlElement(arr, ARRAY_SIZE(arr), &e);
+
+ FeatureParams params;
+ ftype::GetNameAndType(&e, params);
+
+ TEST_EQUAL(params.m_types.size(), 1, (params));
+ TEST_EQUAL(params.m_types[0], GetType(arr[1]), ());
+}
+
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Check)
+{
char const * arr1[][2] = {
{ "highway", "primary" },
{ "motorroad", "yes" },
@@ -121,7 +119,7 @@ UNIT_TEST(OsmType_Check)
DumpParsedTypes(arr4, ARRAY_SIZE(arr4));
}
-UNIT_TEST(OsmType_Combined)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Combined)
{
char const * arr[][2] = {
{ "addr:housenumber", "84" },
@@ -149,7 +147,7 @@ UNIT_TEST(OsmType_Combined)
TEST_EQUAL(params.house.Get(), "84", ());
}
-UNIT_TEST(OsmType_Address)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Address)
{
char const * arr[][2] = {
{ "addr:conscriptionnumber", "223" },
@@ -173,7 +171,7 @@ UNIT_TEST(OsmType_Address)
TEST_EQUAL(params.house.Get(), "223/5", ());
}
-UNIT_TEST(OsmType_PlaceState)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_PlaceState)
{
char const * arr[][2] = {
{ "alt_name:vi", "California" },
@@ -202,7 +200,7 @@ UNIT_TEST(OsmType_PlaceState)
TEST_GREATER(params.rank, 1, ());
}
-UNIT_TEST(OsmType_AlabamaRiver)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_AlabamaRiver)
{
char const * arr1[][2] = {
{ "NHD:FCode", "55800" },
@@ -247,7 +245,7 @@ UNIT_TEST(OsmType_AlabamaRiver)
TEST(params.IsTypeExist(GetType({"waterway", "river"})), ());
}
-UNIT_TEST(OsmType_Synonyms)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Synonyms)
{
// Smoke test.
{
@@ -321,7 +319,7 @@ UNIT_TEST(OsmType_Synonyms)
}
}
-UNIT_TEST(OsmType_Capital)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Capital)
{
{
char const * arr[][2] = {
@@ -378,7 +376,7 @@ UNIT_TEST(OsmType_Capital)
}
}
-UNIT_TEST(OsmType_Route)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Route)
{
{
char const * arr[][2] = {
@@ -398,7 +396,7 @@ UNIT_TEST(OsmType_Route)
}
}
-UNIT_TEST(OsmType_Layer)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Layer)
{
{
char const * arr[][2] = {
@@ -487,7 +485,7 @@ UNIT_TEST(OsmType_Layer)
}
}
-UNIT_TEST(OsmType_Amenity)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Amenity)
{
{
char const * arr[][2] = {
@@ -506,7 +504,7 @@ UNIT_TEST(OsmType_Amenity)
}
}
-UNIT_TEST(OsmType_Hwtag)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Hwtag)
{
char const * tags[][2] = {
{"hwtag", "oneway"}, {"hwtag", "private"}, {"hwtag", "lit"}, {"hwtag", "nofoot"}, {"hwtag", "yesfoot"},
@@ -574,7 +572,7 @@ UNIT_TEST(OsmType_Hwtag)
}
}
-UNIT_TEST(OsmType_Surface)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Surface)
{
TestSurfaceTypes("asphalt", "", "", "paved_good");
TestSurfaceTypes("asphalt", "bad", "", "paved_bad");
@@ -594,7 +592,7 @@ UNIT_TEST(OsmType_Surface)
TestSurfaceTypes("", "unknown", "", "unpaved_good");
}
-UNIT_TEST(OsmType_Ferry)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Ferry)
{
routing::CarModel const & carModel = routing::CarModel::AllLimitsInstance();
@@ -629,7 +627,7 @@ UNIT_TEST(OsmType_Ferry)
TEST(params.IsTypeExist(type), ());
}
-UNIT_TEST(OsmType_Boundary)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Boundary)
{
char const * arr[][2] = {
{ "admin_level", "4" },
@@ -649,7 +647,7 @@ UNIT_TEST(OsmType_Boundary)
TEST(params.IsTypeExist(GetType({"boundary", "administrative", "4"})), ());
}
-UNIT_TEST(OsmType_Dibrugarh)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Dibrugarh)
{
char const * arr[][2] = {
{ "AND_a_c", "10001373" },
@@ -676,7 +674,7 @@ UNIT_TEST(OsmType_Dibrugarh)
TEST_EQUAL(name, "Dibrugarh", (params));
}
-UNIT_TEST(OsmType_Subway)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Subway)
{
{
char const * arr[][2] = {
@@ -778,7 +776,7 @@ UNIT_TEST(OsmType_Subway)
}
}
-UNIT_TEST(OsmType_Hospital)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Hospital)
{
{
char const * arr[][2] = {
@@ -813,7 +811,7 @@ UNIT_TEST(OsmType_Hospital)
}
}
-UNIT_TEST(OsmType_Entrance)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Entrance)
{
{
char const * arr[][2] = {
@@ -836,7 +834,7 @@ UNIT_TEST(OsmType_Entrance)
}
}
-UNIT_TEST(OsmType_Moscow)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Moscow)
{
{
char const * arr[][2] = {
@@ -873,7 +871,7 @@ UNIT_TEST(OsmType_Moscow)
}
}
-UNIT_TEST(OsmType_Translations)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Translations)
{
char const * arr[][2] = {
{ "name", "Paris" },
@@ -904,7 +902,7 @@ UNIT_TEST(OsmType_Translations)
TEST_EQUAL(name, "Париж", (params));
}
-UNIT_TEST(OsmType_Cuisine)
+UNIT_CLASS_TEST(TestWithClassificator, OsmType_Cuisine)
{
{
char const * arr[][2] = {
diff --git a/indexer/indexer_tests/classificator_tests.cpp b/indexer/indexer_tests/classificator_tests.cpp
index 325b1e5aff..0a7e881744 100644
--- a/indexer/indexer_tests/classificator_tests.cpp
+++ b/indexer/indexer_tests/classificator_tests.cpp
@@ -1,30 +1,18 @@
#include "testing/testing.hpp"
#include "indexer/classificator.hpp"
-#include "indexer/classificator_loader.hpp"
+
+#include "generator/generator_tests_support/test_with_classificator.hpp"
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
+using namespace generator::tests_support;
using namespace std;
-namespace
-{
-class ClassificatorTest
-{
-public:
- ClassificatorTest()
- {
- classificator::Load();
- }
-
- ~ClassificatorTest() = default;
-};
-} // namespace
-
-UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetType)
+UNIT_CLASS_TEST(TestWithClassificator, Classificator_GetType)
{
Classificator const & c = classif();
@@ -43,7 +31,7 @@ UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetType)
TEST(!c.IsTypeValid(0), ());
}
-UNIT_CLASS_TEST(ClassificatorTest, Classificator_CoastlineType)
+UNIT_CLASS_TEST(TestWithClassificator, Classificator_CoastlineType)
{
Classificator const & c = classif();
@@ -52,7 +40,7 @@ UNIT_CLASS_TEST(ClassificatorTest, Classificator_CoastlineType)
TEST_EQUAL(type, c.GetCoastType(), ());
}
-UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetIndex)
+UNIT_CLASS_TEST(TestWithClassificator, Classificator_GetIndex)
{
Classificator const & c = classif();
@@ -62,7 +50,7 @@ UNIT_CLASS_TEST(ClassificatorTest, Classificator_GetIndex)
TEST_EQUAL(type, c.GetTypeForIndex(index), ());
}
-UNIT_CLASS_TEST(ClassificatorTest, Classificator_Subtree)
+UNIT_CLASS_TEST(TestWithClassificator, Classificator_Subtree)
{
Classificator const & c = classif();
diff --git a/routing/routing_integration_tests/get_altitude_test.cpp b/routing/routing_integration_tests/get_altitude_test.cpp
index bddbb7c4af..bc33dc1238 100644
--- a/routing/routing_integration_tests/get_altitude_test.cpp
+++ b/routing/routing_integration_tests/get_altitude_test.cpp
@@ -56,9 +56,6 @@ void TestAltitudeOfAllMwmFeatures(string const & countryId, TAltitude const alti
unique_ptr<AltitudeLoader> altitudeLoader =
make_unique<AltitudeLoader>(dataSource, regResult.first /* mwmId */);
- classificator::Load();
- classif().SortClassificator();
-
ForEachFromDat(country.GetPath(MapOptions::Map), [&](FeatureType & f, uint32_t const & id) {
if (!routing::IsRoad(TypesHolder(f)))
return;
@@ -82,6 +79,8 @@ void TestAltitudeOfAllMwmFeatures(string const & countryId, TAltitude const alti
UNIT_TEST(AllMwmFeaturesGetAltitudeTest)
{
+ classificator::Load();
+
TestAltitudeOfAllMwmFeatures("Russia_Moscow", 50 /* altitudeLowerBoundMeters */,
300 /* altitudeUpperBoundMeters */);
TestAltitudeOfAllMwmFeatures("Nepal_Kathmandu", 250 /* altitudeLowerBoundMeters */,