Unity fixes

This commit is contained in:
Alexander Borsuk 2022-01-01 22:15:30 +01:00
parent e6523f2b92
commit 96f6b2e006
74 changed files with 298 additions and 368 deletions

View file

@ -51,8 +51,8 @@ UNIT_TEST(AlmostEqualULPs_double)
TEST_ALMOST_EQUAL_ULPS(3.0, 3.0, ());
TEST_ALMOST_EQUAL_ULPS(+0.0, -0.0, ());
double const eps = std::numeric_limits<double>::epsilon();
double const dmax = std::numeric_limits<double>::max();
double constexpr eps = std::numeric_limits<double>::epsilon();
double constexpr dmax = std::numeric_limits<double>::max();
TEST_ALMOST_EQUAL_ULPS(1.0 + eps, 1.0, ());
TEST_ALMOST_EQUAL_ULPS(1.0 - eps, 1.0, ());
@ -96,8 +96,8 @@ UNIT_TEST(AlmostEqualULPs_float)
UNIT_TEST(AlmostEqual_Smoke)
{
double const small = 1e-18;
double const eps = 1e-10;
double constexpr small = 1e-18;
double constexpr eps = 1e-10;
TEST(base::AlmostEqualAbs(0.0, 0.0 + small, eps), ());
TEST(!base::AlmostEqualRel(0.0, 0.0 + small, eps), ());

View file

@ -2,6 +2,8 @@
#include "coding/url.hpp"
#include "base/math.hpp"
#include <queue>
#include <string>
#include <utility>

View file

@ -8,7 +8,6 @@ set(SRC
buffer_tests.cpp
dummy_texture.hpp
font_texture_tests.cpp
gl_functions.cpp
gl_mock_functions.cpp
gl_mock_functions.hpp
glyph_mng_tests.cpp

View file

@ -2727,7 +2727,7 @@ m2::AnyRectD TapInfo::GetRoutingPointTapRect(m2::PointD const & mercator, Screen
}
// static
m2::AnyRectD TapInfo::GetPreciseTapRect(m2::PointD const & mercator, double const eps)
m2::AnyRectD TapInfo::GetPreciseTapRect(m2::PointD const & mercator, double eps)
{
return m2::AnyRectD(mercator, ang::AngleD(0.0) /* angle */, m2::RectD(-eps, -eps, eps, eps));
}

View file

@ -71,7 +71,7 @@ struct TapInfo
static m2::AnyRectD GetBookmarkTapRect(m2::PointD const & mercator, ScreenBase const & screen);
static m2::AnyRectD GetRoutingPointTapRect(m2::PointD const & mercator, ScreenBase const & screen);
static m2::AnyRectD GetGuideTapRect(m2::PointD const & mercator, ScreenBase const & screen);
static m2::AnyRectD GetPreciseTapRect(m2::PointD const & mercator, double const eps);
static m2::AnyRectD GetPreciseTapRect(m2::PointD const & mercator, double eps);
};
class FrontendRenderer : public BaseRenderer,

View file

@ -253,7 +253,13 @@ target_link_libraries(${PROJECT_NAME}
$<$<BOOL:CMAKE_DL_LIBS>:${CMAKE_DL_LIBS}> # dladdr from boost::stacktrace
)
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD OFF)
# Disable unity build to avoid boost::geometry macro errors.
set_source_files_properties(
affiliation.cpp
final_processor_country.cpp
hierarchy.cpp
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE
)
omim_add_test_subdirectory(generator_tests_support)
omim_add_test_subdirectory(generator_tests)

View file

@ -19,10 +19,10 @@
BOOST_GEOMETRY_REGISTER_POINT_2D(m2::PointD, double, boost::geometry::cs::cartesian, x, y);
BOOST_GEOMETRY_REGISTER_RING(std::vector<m2::PointD>);
namespace
namespace feature
{
namespace affiliation
{
using namespace feature;
template <typename T>
struct RemoveCvref
{
@ -70,7 +70,7 @@ void ForEachPoint(T && t, F && f)
// An implementation for CountriesFilesAffiliation class.
template <typename T>
std::vector<std::string> GetAffiliations(T && t,
std::vector<std::string> GetAffiliations(T const & t,
borders::CountryPolygonsCollection const & countryPolygonsTree,
bool haveBordersForWholeWorld)
{
@ -168,10 +168,8 @@ std::vector<std::string> GetAffiliations(T && t, IndexSharedPtr const & index)
auto const oneCountry = IsOneCountryForLimitRect(GetLimitRect(t), index);
return oneCountry ? std::vector<std::string>{*oneCountry} : GetHonestAffiliations(t, index);
}
} // namespace
} // namespace affiliation
namespace feature
{
CountriesFilesAffiliation::CountriesFilesAffiliation(std::string const & borderPath, bool haveBordersForWholeWorld)
: m_countryPolygonsTree(borders::GetOrCreateCountryPolygonsTree(borderPath))
, m_haveBordersForWholeWorld(haveBordersForWholeWorld)
@ -180,13 +178,13 @@ CountriesFilesAffiliation::CountriesFilesAffiliation(std::string const & borderP
std::vector<std::string> CountriesFilesAffiliation::GetAffiliations(FeatureBuilder const & fb) const
{
return ::GetAffiliations(fb, m_countryPolygonsTree, m_haveBordersForWholeWorld);
return affiliation::GetAffiliations(fb, m_countryPolygonsTree, m_haveBordersForWholeWorld);
}
std::vector<std::string>
CountriesFilesAffiliation::GetAffiliations(m2::PointD const & point) const
{
return ::GetAffiliations(point, m_countryPolygonsTree, m_haveBordersForWholeWorld);
return affiliation::GetAffiliations(point, m_countryPolygonsTree, m_haveBordersForWholeWorld);
}
bool CountriesFilesAffiliation::HasCountryByName(std::string const & name) const
@ -221,12 +219,12 @@ CountriesFilesIndexAffiliation::CountriesFilesIndexAffiliation(std::string const
std::vector<std::string> CountriesFilesIndexAffiliation::GetAffiliations(FeatureBuilder const & fb) const
{
return ::GetAffiliations(fb, m_index);
return affiliation::GetAffiliations(fb, m_index);
}
std::vector<std::string> CountriesFilesIndexAffiliation::GetAffiliations(m2::PointD const & point) const
{
return ::GetAffiliations(point, m_index);
return affiliation::GetAffiliations(point, m_index);
}
std::shared_ptr<CountriesFilesIndexAffiliation::Tree>
@ -254,7 +252,7 @@ CountriesFilesIndexAffiliation::BuildIndex(const std::vector<m2::RectD> & net)
}
else
{
auto const box = MakeBox(rect);
auto const box = affiliation::MakeBox(rect);
std::vector<std::reference_wrapper<borders::CountryPolygons const>> interCountries;
for (borders::CountryPolygons const & cp : countries)
{
@ -293,7 +291,7 @@ CountriesFilesIndexAffiliation::BuildIndex(const std::vector<m2::RectD> & net)
{
std::vector<std::reference_wrapper<borders::CountryPolygons const>> interCountries{*countryPtr};
std::lock_guard<std::mutex> lock(treeCellsMutex);
treeCells.emplace_back(MakeBox(rect), std::move(interCountries));
treeCells.emplace_back(affiliation::MakeBox(rect), std::move(interCountries));
}
});
}

View file

@ -9,7 +9,7 @@
#include "platform/platform.hpp"
#include "indexer/feature.hpp"
#include "indexer/feature_data.cpp"
#include "indexer/feature_data.hpp"
#include "indexer/feature_processor.hpp"
#include "coding/read_write_utils.hpp"
@ -18,10 +18,12 @@
#include "base/geo_object_id.hpp"
#include "base/logging.hpp"
#include <utility>
#include "defines.hpp"
#include <utility>
namespace routing
{
using namespace generator;
using namespace std;
@ -91,8 +93,6 @@ vector<uint32_t> CalcRoadFeatureIds(string const & dataPath, string const & boun
}
} // namespace
namespace routing
{
void SerializeCityRoads(string const & dataPath, vector<uint32_t> && cityRoadFeatureIds)
{
if (cityRoadFeatureIds.empty())

View file

@ -60,7 +60,7 @@ bool IsSuitablePlaceType(ftypes::LocalityType localityType)
}
}
ftypes::LocalityType GetPlaceType(FeatureBuilder const & feature)
ftypes::LocalityType GetPlaceLocalityType(FeatureBuilder const & feature)
{
return ftypes::IsLocalityChecker::Instance().GetType(feature.GetTypesHolder());
}
@ -156,7 +156,7 @@ RoutingCityBoundariesCollector::RoutingCityBoundariesCollector(
std::shared_ptr<CollectorInterface> RoutingCityBoundariesCollector::Clone(
std::shared_ptr<cache::IntermediateDataReaderInterface> const & cache) const
{
return std::make_shared<RoutingCityBoundariesCollector>(GetFilename(), m_dumpFilename,
return std::make_shared<RoutingCityBoundariesCollector>(GetFilename(), m_dumpFilename,
cache ? cache : m_cache);
}
@ -181,7 +181,7 @@ void RoutingCityBoundariesCollector::Process(feature::FeatureBuilder & feature,
{
ASSERT(FilterOsmElement(osmElement), ());
if (feature.IsArea() && IsSuitablePlaceType(::GetPlaceType(feature)))
if (feature.IsArea() && IsSuitablePlaceType(GetPlaceLocalityType(feature)))
{
if (feature.PreSerialize())
m_writer->Process(feature);
@ -208,7 +208,7 @@ void RoutingCityBoundariesCollector::Process(feature::FeatureBuilder & feature,
}
else if (feature.IsPoint())
{
auto const placeType = ::GetPlaceType(feature);
auto const placeType = GetPlaceLocalityType(feature);
// Elements which have multiple place tags i.e. "place=country" + "place=city" will pass FilterOsmElement()
// but can have bad placeType here. As we do not know what's the real place type let's skip such places.

View file

@ -29,11 +29,11 @@
BOOST_GEOMETRY_REGISTER_POINT_2D(m2::PointD, double, boost::geometry::cs::cartesian, x, y)
BOOST_GEOMETRY_REGISTER_RING(std::vector<m2::PointD>)
namespace generator
{
using namespace base::thread_pool::computational;
using namespace feature;
namespace generator
{
CountryFinalProcessor::CountryFinalProcessor(std::string const & borderPath,
std::string const & temporaryMwmPath,
std::string const & intermediateDir,

View file

@ -430,11 +430,6 @@ private:
classificator::Load();
auto & platform = GetPlatform();
// Should be initialized in testingmain.cpp
//auto const & options = GetTestingOptions();
//platform.SetResourceDir(options.m_resourcePath);
//platform.SetSettingsDir(options.m_resourcePath);
m_threadCount = static_cast<size_t>(platform.CpuCores());
m_testPath = base::JoinPath(platform.WritableDir(), "gen-test");
m_genInfo.SetNodeStorageType("map");

View file

@ -31,14 +31,14 @@
#include <string>
#include <vector>
namespace altitude_test
{
using namespace feature;
using namespace generator;
using namespace platform;
using namespace platform::tests_support;
using namespace routing;
namespace
{
// These tests generate mwms with altitude sections and then check if altitudes
// in the mwms are correct. The mwms are initialized with different sets of features.
// There are several restrictions for these features:
@ -254,4 +254,4 @@ UNIT_TEST(AltitudeGenerationTest_FourRoadsWithoutAltitude)
std::vector<TPoint3DList> const roads = {kRoad1, kRoad2, kRoad3, kRoad4};
TestBuildingNoFeatureHasAltitude(roads, false /* hasAltitudeExpected */);
}
} // namespace
} // namespace altitude_test

View file

@ -32,14 +32,14 @@
#include "defines.hpp"
namespace city_roads_tests
{
using namespace coding;
using namespace platform::tests_support;
using namespace platform;
using namespace routing;
using namespace std;
namespace
{
// Directory name for creating test mwm and temporary files.
string const kTestDir = "city_roads_generation_test";
// Temporary mwm name for testing.
@ -173,4 +173,4 @@ UNIT_TEST(CityRoadsGenerationTest_UnsortedIds3)
182452, 303265, 73616, 262562, 62935, 294606, 466803, 215791, 468825, 76934, 18187,
194429, 32913}));
}
} // namespace
} // namespace city_roads_tests

View file

@ -20,13 +20,13 @@
#include <utility>
#include <vector>
namespace collector_boundary_postcode_tests
{
using namespace generator_tests;
using namespace generator;
using namespace feature;
using namespace std;
namespace
{
using BoundariesCollector = RoutingCityBoundariesCollector;
string const kDumpFileName = "dump.bin";
@ -132,7 +132,7 @@ bool CheckPostcodeExists(unordered_map<string, vector<m2::PointD>> const & data,
for (size_t i = 0; i < geometry.size(); ++i)
{
if (!base::AlmostEqualAbs(geometry[i], it->second[i], kMwmPointAccuracy))
if (!m2::AlmostEqualAbs(geometry[i], it->second[i], kMwmPointAccuracy))
return false;
}
@ -160,7 +160,7 @@ void Check(string const & dumpFilename)
TEST(CheckPostcodeExists(data, "127003", ConvertIdsToPoints(kPolygon3)), (data));
TEST(CheckPostcodeExists(data, "127004", ConvertIdsToPoints(kPolygon4)), (data));
}
} // namespace
UNIT_TEST(CollectorBoundaryPostcode_1)
{
@ -200,3 +200,4 @@ UNIT_TEST(CollectorBoundaryPostcode_2)
Check(kDumpFileName);
}
} // namespace collector_boundary_postcode_tests

View file

@ -17,7 +17,7 @@
#include <memory>
#include <unordered_map>
namespace
namespace collector_building_parts_tests
{
using namespace generator::tests_support;
@ -241,4 +241,4 @@ UNIT_CLASS_TEST(TestWithClassificator, CollectorBuildingParts_Case2)
TestCollector(file.GetFullPath(), fb2, *intermediateReader,
IntermediateDataReaderTest::kTopRelationId2);
}
} // namespace
} // namespace collector_building_parts_tests

View file

@ -20,10 +20,10 @@
#include <memory>
#include <vector>
namespace collector_city_area_tests
{
using namespace generator_tests;
namespace
{
feature::FeatureBuilder MakeFbForTest(OsmElement element)
{
feature::FeatureBuilder result;
@ -45,7 +45,6 @@ auto const o1 = MakeOsmElement(1 /* id */, {{"place", "city"}} /* tags */, OsmEl
auto const o2 = MakeOsmElement(2 /* id */, {{"place", "town"}} /* tags */, OsmElement::EntityType::Relation);
auto const o3 = MakeOsmElement(3 /* id */, {{"place", "village"}} /* tags */, OsmElement::EntityType::Relation);
auto const o4 = MakeOsmElement(4 /* id */, {{"place", "country"}} /* tags */, OsmElement::EntityType::Relation);
} // namespace
UNIT_TEST(CollectorCityArea_Merge)
{
@ -70,3 +69,4 @@ UNIT_TEST(CollectorCityArea_Merge)
TEST(HasRelationWithId(fbs, 2 /* id */), ());
TEST(HasRelationWithId(fbs, 3 /* id */), ());
}
} // namespace collector_city_area_tests

View file

@ -22,13 +22,13 @@
#include <memory>
#include <vector>
namespace collector_routing_city_boundaries_tests
{
using namespace generator_tests;
using namespace generator;
using namespace tests_support;
using namespace generator::tests_support;
using namespace feature;
namespace
{
using BoundariesCollector = RoutingCityBoundariesCollector;
std::string const kDumpFileName = "dump.bin";
@ -131,7 +131,7 @@ bool CheckPolygonExistance(std::vector<std::vector<m2::PointD>> const & polygons
for (size_t i = 0; i < polygon.size(); ++i)
{
if (!base::AlmostEqualAbs(polygon[i], polygonToFind[i], 1e-6))
if (!m2::AlmostEqualAbs(polygon[i], polygonToFind[i], 1e-6))
{
same = false;
break;
@ -202,7 +202,7 @@ double CalculateEarthAreaForConvexPolygon(std::vector<ms::LatLon> const & latlon
return area;
}
} // namespace
UNIT_CLASS_TEST(TestWithClassificator, CollectorRoutingCityBoundaries_1)
{
@ -210,7 +210,7 @@ UNIT_CLASS_TEST(TestWithClassificator, CollectorRoutingCityBoundaries_1)
SCOPE_GUARD(_, std::bind(Platform::RemoveFileIfExists, std::cref(filename)));
SCOPE_GUARD(rmDump, std::bind(Platform::RemoveFileIfExists, std::cref(kDumpFileName)));
std::shared_ptr<cache::IntermediateDataReader> cache;
std::shared_ptr<generator::cache::IntermediateDataReader> cache;
auto c1 = std::make_shared<BoundariesCollector>(filename, kDumpFileName, cache);
Collect(*c1, {placeRelation1, placeRelation2, placeRelation3, placeRelation4},
@ -231,7 +231,7 @@ UNIT_CLASS_TEST(TestWithClassificator, CollectorRoutingCityBoundaries_2)
SCOPE_GUARD(_, std::bind(Platform::RemoveFileIfExists, std::cref(filename)));
SCOPE_GUARD(rmDump, std::bind(Platform::RemoveFileIfExists, std::cref(kDumpFileName)));
std::shared_ptr<cache::IntermediateDataReader> cache;
std::shared_ptr<generator::cache::IntermediateDataReader> cache;
auto c1 = std::make_shared<BoundariesCollector>(filename, kDumpFileName, cache);
auto c2 = c1->Clone();
@ -329,3 +329,4 @@ UNIT_TEST(AreaOnEarth_Concave_Polygon)
areaOnEarth,
1e-6), ());
}
} // namespace collector_routing_city_boundaries_tests

View file

@ -8,7 +8,7 @@
#include "platform/platform.hpp"
#include "indexer/classificator_loader.cpp"
#include "indexer/classificator_loader.hpp"
#include "geometry/mercator.hpp"
@ -23,11 +23,11 @@
#include <utility>
#include <vector>
namespace cross_mwm_osm_ways_collector_tests
{
using namespace generator;
using namespace generator_tests;
namespace
{
std::string const kTmpDirName = "cross_mwm_ways";
std::vector<std::string> const kHighwayUnclassifiedPath = {"highway", "unclassified"};
@ -202,4 +202,4 @@ UNIT_CLASS_TEST(CrossMwmWayCollectorTest, TwoCollectorTest)
Checker();
}
} // namespace
} // namespace cross_mwm_osm_ways_collector_tests

View file

@ -28,11 +28,9 @@
#include <utility>
#include <vector>
using namespace generator;
namespace
namespace generator_tests
{
class Feature : public tests_support::TestFeature
class Feature : public generator::tests_support::TestFeature
{
public:
Feature() = default;
@ -53,10 +51,7 @@ public:
private:
std::vector<uint32_t> m_types;
};
} // namespace
namespace generator_tests
{
class TestDescriptionSectionBuilder
{
public:
@ -343,11 +338,8 @@ private:
};
std::string const TestDescriptionSectionBuilder::kMwmFile = "MwmFile";
std::string const TestDescriptionSectionBuilder::kDirPages = "wiki";
} // namespace generator_tests
using namespace generator_tests;
UNIT_CLASS_TEST(TestDescriptionSectionBuilder, DescriptionsCollectionBuilder_MakeDescriptions)
{
@ -379,8 +371,6 @@ UNIT_CLASS_TEST(TestDescriptionSectionBuilder, DescriptionsCollectionBuilder_Bui
TestDescriptionSectionBuilder::BuildDescriptionsSection();
}
namespace generator_tests
{
// http://en.wikipedia.org/wiki/Helsinki_Olympic_Stadium/ - en, de, ru, fr
// https://en.wikipedia.org/wiki/Turku_Cathedral - en, ru

View file

@ -7,7 +7,7 @@
#include "generator/geometry_holder.hpp"
#include "generator/osm2type.hpp"
#include "indexer/data_header.cpp"
#include "indexer/data_header.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/feature_visibility.hpp"
@ -15,8 +15,9 @@
#include <limits>
namespace feature_builder_test
{
using namespace feature;
using namespace generator::tests_support;
using namespace tests;
@ -343,3 +344,4 @@ UNIT_CLASS_TEST(TestWithClassificator, FBuilder_RemoveUselessAltName)
TEST(fb.IsValid(), (fb));
}
}
} // namespace feature_builder_test

View file

@ -10,11 +10,11 @@
#include "base/geo_object_id.hpp"
namespace hierarchy_entry_tests
{
using generator::tests_support::TestWithClassificator;
using platform::tests_support::ScopedFile;
namespace
{
std::string const kCsv1 =
"13835058055284963881 9223372037111861697;"
";"
@ -146,4 +146,4 @@ UNIT_CLASS_TEST(TestWithClassificator, Complex_LoadHierachy)
MakeId(9223372036879747192ull, 9223372036879747192ull), ());
TEST_EQUAL(node->GetChildren().size(), 0, ());
}
} // namespace
} // namespace hierarchy_entry_tests

View file

@ -2,7 +2,7 @@
#include "generator/feature_builder.hpp"
#include "generator/generator_tests/common.hpp"
#include "generator/generator_tests_support/test_feature.cpp"
#include "generator/generator_tests_support/test_feature.hpp"
#include "generator/generator_tests_support/test_mwm_builder.hpp"
#include "generator/maxspeeds_builder.hpp"
#include "generator/maxspeeds_collector.hpp"
@ -45,9 +45,8 @@
#include <string>
#include <vector>
namespace
namespace maxspeeds_tests
{
using namespace generator;
using namespace generator_tests;
using namespace measurement_utils;
@ -137,8 +136,6 @@ bool ParseCsv(string const & maxspeedsCsvContent, OsmIdToMaxspeed & mapping)
return ParseMaxspeeds(base::JoinPath(testDirFullPath, kCsv), mapping);
}
} // namespace
UNIT_TEST(MaxspeedTagValueToSpeedTest)
{
SpeedInUnits speed;
@ -438,3 +435,4 @@ UNIT_TEST(MaxspeedCollector_Smoke)
TEST_EQUAL(osmIdToMaxspeed[base::MakeOsmWay(5)].GetForward(), static_cast<MaxspeedType>(20), ());
}
} // namespace maxspeeds_tests

View file

@ -20,10 +20,10 @@
#include <string>
#include <vector>
namespace metalines_tests
{
using namespace feature;
namespace
{
OsmElement MakeHighway(uint64_t id, std::string const & name, std::vector<uint64_t> const & nodes,
bool isOneway = false)
{
@ -82,7 +82,7 @@ auto const wo8 = MakeHighway(8/* id */, "w" /* name */, {17, 16, 15} /* nodes */
auto const b1 = MakeHighway(1/* id */, "b" /* name */, {1, 2, 3} /* nodes */);
auto const b2 = MakeHighway(2/* id */, "b" /* name */, {3, 4, 5} /* nodes */);
} // namespace
UNIT_TEST(MetalinesTest_Case0)
{
@ -197,3 +197,4 @@ UNIT_TEST(MetalinesTest_MetalinesBuilderMarge)
TEST_EQUAL(s.count({1, 2}), 1, ());
TEST_EQUAL(s.count({4, 5}), 1, ());
}
} // namespace metalines_tests

View file

@ -15,10 +15,10 @@
#include <array>
#include <vector>
namespace mini_roundabout_tests
{
using namespace generator;
namespace
{
OsmElement MiniRoundabout(uint64_t id, double lat, double lon)
{
OsmElement miniRoundabout;
@ -49,15 +49,13 @@ OsmElement RoadNode(uint64_t id, double lat, double lon)
return node;
}
} // namespace
void TestRunCmpPoints(std::vector<m2::PointD> const & pointsFact,
std::vector<m2::PointD> const & pointsPlan, double r)
{
TEST_EQUAL(pointsFact.size(), pointsPlan.size(), ());
TEST_GREATER(pointsFact.size(), 2, ());
for (size_t i = 0; i < pointsFact.size(); ++i)
TEST(AlmostEqualAbs(pointsFact[i], pointsPlan[i], kMwmPointAccuracy), ());
TEST(m2::AlmostEqualAbs(pointsFact[i], pointsPlan[i], kMwmPointAccuracy), ());
}
void TestRunCmpNumbers(double val1, double val2)
@ -99,7 +97,7 @@ UNIT_TEST(TrimSegment_Vertical)
double const dist = 1.0;
m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist);
m2::PointD const pointPlan(2.0, 2.0);
TEST(AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ());
TEST(m2::AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ());
}
UNIT_TEST(TrimSegment_VerticalNegative)
@ -109,7 +107,7 @@ UNIT_TEST(TrimSegment_VerticalNegative)
double const dist = 4.0;
m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist);
m2::PointD const pointPlan(-3.0, 2.0);
TEST(AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ());
TEST(m2::AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ());
}
UNIT_TEST(TrimSegment_ExceptionalCase)
@ -118,7 +116,7 @@ UNIT_TEST(TrimSegment_ExceptionalCase)
m2::PointD const b(2.0, 3.0);
double const dist = 10.0;
m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist);
TEST(AlmostEqualAbs(point, a, kMwmPointAccuracy), ());
TEST(m2::AlmostEqualAbs(point, a, kMwmPointAccuracy), ());
}
UNIT_TEST(PointToCircle_ZeroMeridian)
@ -278,3 +276,4 @@ UNIT_TEST(Manage_MiniRoundabout_EqualPoints)
AddPointToCircle(circlePlain, circlePlain[0]);
TEST_EQUAL(circlePlain.size(), 16, ());
}
} // namespace mini_roundabout_tests

View file

@ -19,67 +19,67 @@
#include <string>
#include <vector>
namespace osm_type_test
{
using namespace generator::tests_support;
using namespace tests;
using Tags = std::vector<OsmElement::Tag>;
namespace
void DumpTypes(std::vector<uint32_t> const & v)
{
void DumpTypes(std::vector<uint32_t> const & v)
Classificator const & c = classif();
for (size_t i = 0; i < v.size(); ++i)
std::cout << c.GetFullObjectName(v[i]) << std::endl;
}
void DumpParsedTypes(Tags const & tags)
{
OsmElement e;
FillXmlElement(tags, &e);
FeatureBuilderParams params;
ftype::GetNameAndType(&e, params);
DumpTypes(params.m_types);
}
void TestSurfaceTypes(std::string const & surface, std::string const & smoothness,
std::string const & grade, char const * value)
{
OsmElement e;
e.AddTag("highway", "unclassified");
e.AddTag("surface", surface);
e.AddTag("smoothness", smoothness);
e.AddTag("surface:grade", grade);
FeatureBuilderParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_types.size(), 2, (params));
TEST(params.IsTypeExist(GetType({"highway", "unclassified"})), ());
std::string psurface;
for (auto type : params.m_types)
{
Classificator const & c = classif();
for (size_t i = 0; i < v.size(); ++i)
std::cout << c.GetFullObjectName(v[i]) << std::endl;
std::string const rtype = classif().GetReadableObjectName(type);
if (rtype.substr(0, 9) == "psurface-")
psurface = rtype.substr(9);
}
TEST(params.IsTypeExist(GetType({"psurface", value})),
("Surface:", surface, "Smoothness:", smoothness, "Grade:", grade, "Expected:", value,
"Got:", psurface));
}
void DumpParsedTypes(Tags const & tags)
{
OsmElement e;
FillXmlElement(tags, &e);
FeatureBuilderParams GetFeatureBuilderParams(Tags const & tags)
{
OsmElement e;
FillXmlElement(tags, &e);
FeatureBuilderParams params;
FeatureBuilderParams params;
ftype::GetNameAndType(&e, params);
ftype::GetNameAndType(&e, params);
return params;
}
DumpTypes(params.m_types);
}
void TestSurfaceTypes(std::string const & surface, std::string const & smoothness,
std::string const & grade, char const * value)
{
OsmElement e;
e.AddTag("highway", "unclassified");
e.AddTag("surface", surface);
e.AddTag("smoothness", smoothness);
e.AddTag("surface:grade", grade);
FeatureBuilderParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_types.size(), 2, (params));
TEST(params.IsTypeExist(GetType({"highway", "unclassified"})), ());
std::string psurface;
for (auto type : params.m_types)
{
std::string const rtype = classif().GetReadableObjectName(type);
if (rtype.substr(0, 9) == "psurface-")
psurface = rtype.substr(9);
}
TEST(params.IsTypeExist(GetType({"psurface", value})),
("Surface:", surface, "Smoothness:", smoothness, "Grade:", grade, "Expected:", value,
"Got:", psurface));
}
FeatureBuilderParams GetFeatureBuilderParams(Tags const & tags)
{
OsmElement e;
FillXmlElement(tags, &e);
FeatureBuilderParams params;
ftype::GetNameAndType(&e, params);
return params;
}
} // namespace
UNIT_CLASS_TEST(TestWithClassificator, OsmType_SkipDummy)
{
@ -2196,3 +2196,4 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_ComplexTypesSmoke)
TEST(params.IsTypeExist(GetType(type.first)), (type, params));
}
}
} // namespace osm_type_test

View file

@ -29,16 +29,15 @@
#include <utility>
#include <vector>
using namespace std;
namespace restriction_test
{
using namespace feature;
using namespace generator;
using namespace platform::tests_support;
using namespace platform;
using namespace routing;
using namespace std;
namespace
{
// Directory name for creating test mwm and temporary files.
string const kTestDir = "restriction_generation_test";
// Temporary mwm name for testing.
@ -93,8 +92,8 @@ void BuildEmptyMwm(LocalCountryFile & country)
generator::tests_support::TestMwmBuilder builder(country, feature::DataHeader::MapType::Country);
}
void LoadRestrictions(string const & mwmFilePath,
vector<Restriction> & restrictions,
void LoadRestrictions(string const & mwmFilePath,
vector<Restriction> & restrictions,
vector<RestrictionUTurnForTests> & restrictionsUTurn)
{
FilesContainerR const cont(mwmFilePath);
@ -137,7 +136,7 @@ void LoadRestrictions(string const & mwmFilePath,
/// loads the restriction section and test loaded restrictions.
/// \param |restrictionPath| comma separated text with restrictions in osm id terms.
/// \param |osmIdsToFeatureIdContent| comma separated text with mapping from osm ids to feature ids.
void TestRestrictionBuilding(string const & restrictionPath,
void TestRestrictionBuilding(string const & restrictionPath,
string const & osmIdsToFeatureIdContent,
unique_ptr<IndexGraph> graph,
vector<Restriction> & expectedNotUTurn,
@ -435,4 +434,4 @@ UNIT_TEST(RestrictionGenerationTest_WithUTurn_BadConnection_1)
TestRestrictionBuilding(restrictionPath, osmIdsToFeatureIdsContent, move(indexGraph),
expectedNotUTurn, expectedUTurn);
}
} // namespace
} // namespace restriction_test

View file

@ -31,8 +31,8 @@
#include <string>
#include <vector>
using namespace std;
namespace road_access_test
{
using namespace feature;
using namespace generator::tests_support;
using namespace generator;
@ -41,8 +41,6 @@ using namespace platform;
using namespace routing;
using namespace std;
namespace
{
string const kTestDir = "road_access_generation_test";
string const kTestMwm = "test";
string const kRoadAccessFilename = "road_access_in_osm_ids.csv";
@ -415,4 +413,4 @@ UNIT_TEST(RoadAccessWriter_Conditional_WinterRoads)
TEST_EQUAL(resultFile, expectedFile, ());
}
} // namespace
} // namespace road_access_test

View file

@ -50,6 +50,8 @@
#include <utility>
#include <vector>
namespace speed_cameras_test
{
using namespace feature;
using namespace generator;
using namespace measurement_utils;
@ -58,8 +60,6 @@ using namespace platform;
using namespace routing;
using namespace std;
namespace
{
// Directory name for creating test mwm and temporary files.
string const kTestDir = "speed_camera_generation_test";
@ -505,4 +505,4 @@ UNIT_TEST(RoadCategoryToSpeedTest)
TEST(!RoadCategoryToSpeed("UNKNOWN:unknown", speed), ());
}
} // namespace
} // namespace speed_cameras_test

View file

@ -12,7 +12,7 @@
#include "generator/feature_generator.hpp"
#include "generator/feature_sorter.hpp"
#include "generator/generate_info.hpp"
#include "generator/isolines_section_builder.cpp"
#include "generator/isolines_section_builder.hpp"
#include "generator/maxspeeds_builder.hpp"
#include "generator/metalines_builder.hpp"
#include "generator/osm_source.hpp"

View file

@ -31,7 +31,7 @@ public:
// For FeatureType serialization maxNumTriangles should be less than numeric_limits<uint8_t>::max
// because FeatureType format uses uint8_t to encode the number of triangles.
GeometryHolder(FileGetter geoFileGetter, FileGetter trgFileGetter, FeatureBuilder & fb,
feature::DataHeader const & header, size_t maxNumTriangles = 14)
DataHeader const & header, size_t maxNumTriangles = 14)
: m_geoFileGetter(geoFileGetter)
, m_trgFileGetter(trgFileGetter)
, m_fb(fb)
@ -42,7 +42,7 @@ public:
{
}
GeometryHolder(FeatureBuilder & fb, feature::DataHeader const & header,
GeometryHolder(FeatureBuilder & fb, DataHeader const & header,
size_t maxNumTriangles = 14)
: m_fb(fb)
, m_ptsInner(true)

View file

@ -27,12 +27,12 @@
BOOST_GEOMETRY_REGISTER_POINT_2D(m2::PointD, double, boost::geometry::cs::cartesian, x, y);
BOOST_GEOMETRY_REGISTER_RING(std::vector<m2::PointD>);
using namespace feature;
namespace generator
{
namespace hierarchy
{
using namespace feature;
namespace
{
double CalculateOverlapPercentage(std::vector<m2::PointD> const & lhs,

View file

@ -53,7 +53,7 @@ feature::FeatureBuilder::PointSeq::iterator GetIterOnRoad(m2::PointD const & poi
feature::FeatureBuilder::PointSeq & road)
{
return base::FindIf(road, [&point](m2::PointD const & pointOnRoad) {
return base::AlmostEqualAbs(pointOnRoad, point, kMwmPointAccuracy);
return m2::AlmostEqualAbs(pointOnRoad, point, kMwmPointAccuracy);
});
}
}
@ -188,7 +188,7 @@ feature::FeatureBuilder::PointSeq MiniRoundaboutTransformer::CreateSurrogateRoad
*itPointOnSurrogateRoad /* source */, roundaboutOnRoad.m_location /* target */,
m_radiusMercator /* dist */);
if (AlmostEqualAbs(nextPointOnSurrogateRoad, *itPointOnSurrogateRoad, kMwmPointAccuracy))
if (m2::AlmostEqualAbs(nextPointOnSurrogateRoad, *itPointOnSurrogateRoad, kMwmPointAccuracy))
return {};
AddPointToCircle(roundaboutCircle, nextPointOnSurrogateRoad);
@ -214,7 +214,7 @@ bool MiniRoundaboutTransformer::AddRoundaboutToRoad(RoundaboutUnit const & round
GetPointAtDistFromTarget(*itPointNearRoundabout /* source */, roundaboutCenter /* target */,
m_radiusMercator /* dist */);
if (AlmostEqualAbs(nextPointOnRoad, *itPointNearRoundabout, kMwmPointAccuracy))
if (m2::AlmostEqualAbs(nextPointOnRoad, *itPointNearRoundabout, kMwmPointAccuracy))
return false;
if (isMiddlePoint)
@ -403,7 +403,7 @@ void AddPointToCircle(std::vector<m2::PointD> & circle, m2::PointD const & point
if (iDist1 > iDist2)
std::swap(iDist1, iDist2);
if (iDist1 == 0 && iDist2 == circle.size() - 1)
circle.push_back(point);
else

View file

@ -29,7 +29,6 @@ char const kNo[] = "No";
char const kOnly[] = "Only";
char const kNoUTurn[] = "NoUTurn";
char const kOnlyUTurn[] = "OnlyUTurn";
char const kDelim[] = ", \t\r\n";
bool ParseLineOfWayIds(strings::SimpleTokenizer & iter, std::vector<base::GeoObjectId> & numbers)
{
@ -87,7 +86,7 @@ bool RestrictionCollector::ParseRestrictions(std::string const & path)
std::string line;
while (std::getline(stream, line))
{
strings::SimpleTokenizer iter(line, kDelim);
strings::SimpleTokenizer iter(line, ", \t\r\n");
if (!iter) // the line is empty
return false;

View file

@ -4,7 +4,7 @@
#include "routing/index_graph_loader.hpp"
#include "routing_common/car_model.cpp"
#include "routing_common/car_model.hpp"
#include "routing_common/vehicle_model.hpp"
#include "platform/country_file.hpp"

View file

@ -33,6 +33,8 @@
#include "3party/opening_hours/opening_hours.hpp"
namespace routing
{
using namespace feature;
using namespace routing;
using namespace generator;
@ -40,8 +42,6 @@ using namespace std;
namespace
{
char constexpr kDelim[] = " \t\r\n";
using TagMapping = routing::RoadAccessTagProcessor::TagMapping;
using ConditionalTagsList = routing::RoadAccessTagProcessor::ConditionalTagsList;
@ -205,7 +205,7 @@ bool ParseRoadAccess(string const & roadAccessPath, OsmIdToFeatureIds const & os
if (!getline(stream, line))
break;
strings::SimpleTokenizer iter(line, kDelim);
strings::SimpleTokenizer iter(line, " \t\r\n");
if (!iter)
{
@ -403,8 +403,6 @@ string GetVehicleTypeForAccessConditional(string const & accessConditionalTag)
}
} // namespace
namespace routing
{
// RoadAccessTagProcessor --------------------------------------------------------------------------
RoadAccessTagProcessor::RoadAccessTagProcessor(VehicleType vehicleType)
: m_vehicleType(vehicleType)

View file

@ -400,15 +400,15 @@ void CalcCrossMwmTransitionsExperimental(
}
auto reader = cont.GetReader(TRANSIT_FILE_TAG);
transit::experimental::TransitData transitData;
::transit::experimental::TransitData transitData;
transitData.DeserializeForCrossMwm(*reader.GetPtr());
auto const & stops = transitData.GetStops();
auto const & edges = transitData.GetEdges();
auto const getStopIdPoint = [&stops](transit::TransitId stopId) {
auto const getStopIdPoint = [&stops](::transit::TransitId stopId) {
auto const it = find_if(
stops.begin(), stops.end(),
[stopId](transit::experimental::Stop const & stop) { return stop.GetId() == stopId; });
[stopId](::transit::experimental::Stop const & stop) { return stop.GetId() == stopId; });
CHECK(it != stops.end(),
("stopId:", stopId, "is not found in stops. Size of stops:", stops.size()));

View file

@ -52,7 +52,7 @@ namespace
UNIT_TEST(Average)
{
double const eps = 1.0E-3;
double constexpr eps = 1.0E-3;
double arr1[] = { math::pi-eps, -math::pi+eps };
TEST(is_equal_angle(ang::GetMiddleAngle(arr1[0], arr1[1]), math::pi), ());
@ -74,7 +74,7 @@ UNIT_TEST(ShortestDistance)
UNIT_TEST(TwoVectorsAngle)
{
double const eps = 1e-10;
double constexpr eps = 1e-10;
TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */,
m2::Point<double>(0, 1) /* p1 */,
m2::Point<double>(1, 0)) /* p2 */, 3 * math::pi2, eps), ());

View file

@ -235,7 +235,7 @@ std::string DebugPrint(m2::Point<T> const & p)
}
template <typename T>
bool AlmostEqualAbs(m2::Point<T> const & a, m2::Point<T> const & b, double const eps)
bool AlmostEqualAbs(m2::Point<T> const & a, m2::Point<T> const & b, double eps)
{
return base::AlmostEqualAbs(a.x, b.x, eps) && base::AlmostEqualAbs(a.y, b.y, eps);
}
@ -309,7 +309,7 @@ bool AlmostEqualULPs(m2::Point<T> const & p1, m2::Point<T> const & p2, unsigned
}
template <typename T>
bool AlmostEqualAbs(m2::Point<T> const & p1, m2::Point<T> const & p2, double const & eps)
bool AlmostEqualAbs(m2::Point<T> const & p1, m2::Point<T> const & p2, double eps)
{
return m2::AlmostEqualAbs(p1, p2, eps);
}

View file

@ -164,7 +164,7 @@ namespace polygon_detail
/// Make single strip for the range of points [beg, end), started with index = i.
template <typename F>
void MakeSingleStripFromIndex(size_t i, size_t n, F & f)
void MakeSingleStripFromIndex(size_t i, size_t n, F && f)
{
ASSERT_LESS(i, n, ());
f(i);

View file

@ -1,9 +1,8 @@
#include "testing/testing.hpp"
#include "platform/platform_tests_support/scoped_mwm.cpp"
#include "platform/platform_tests_support/scoped_mwm.hpp"
#include "indexer/indexer_tests/test_mwm_set.hpp"
#include "indexer/mwm_set.hpp"
#include "base/macros.hpp"
@ -11,16 +10,16 @@
#include <initializer_list>
#include <unordered_map>
namespace mwm_set_test
{
using namespace platform::tests_support;
using namespace std;
using platform::CountryFile;
using platform::LocalCountryFile;
using tests::TestMwmSet;
using namespace platform::tests_support;
using MwmsInfo = unordered_map<string, shared_ptr<MwmInfo>>;
namespace
{
void GetMwmsInfo(MwmSet const & mwmSet, MwmsInfo & mwmsInfo)
{
vector<shared_ptr<MwmInfo>> mwmsInfoList;
@ -37,7 +36,6 @@ void TestFilesPresence(MwmsInfo const & mwmsInfo, initializer_list<string> const
for (string const & countryFileName : expectedNames)
TEST_EQUAL(1, mwmsInfo.count(countryFileName), (countryFileName));
}
} // namespace
UNIT_TEST(MwmSetSmokeTest)
{
@ -171,3 +169,4 @@ UNIT_TEST(MwmSetLockAndIdTest)
TEST(!handle.GetId().IsAlive(), ());
TEST(!handle.GetId().GetInfo().get(), ());
}
} // namespace mwm_set_test

View file

@ -11,39 +11,24 @@
#include "base/logging.hpp"
#include "base/stl_helpers.hpp"
namespace classificator_tests
{
using namespace std;
namespace
class DoCheckConsistency
{
void UnitTestInitPlatform()
{
Platform & pl = GetPlatform();
CommandLineOptions const & options = GetTestingOptions();
if (options.m_dataPath)
pl.SetWritableDirForTests(options.m_dataPath);
if (options.m_resourcePath)
pl.SetResourceDir(options.m_resourcePath);
}
}
namespace
{
class DoCheckConsistency
Classificator const & m_c;
public:
explicit DoCheckConsistency(Classificator const & c) : m_c(c) {}
void operator() (ClassifObject const * p, uint32_t type) const
{
Classificator const & m_c;
public:
explicit DoCheckConsistency(Classificator const & c) : m_c(c) {}
void operator() (ClassifObject const * p, uint32_t type) const
{
if (p->IsDrawableAny() && !m_c.IsTypeValid(type))
TEST(false, ("Inconsistency type", type, m_c.GetFullObjectName(type)));
}
};
} // namespace
if (p->IsDrawableAny() && !m_c.IsTypeValid(type))
TEST(false, ("Inconsistency type", type, m_c.GetFullObjectName(type)));
}
};
UNIT_TEST(Classificator_CheckConsistency)
{
UnitTestInitPlatform();
styles::RunForEveryMapStyle([](MapStyle)
{
Classificator const & c = classif();
@ -118,7 +103,6 @@ void CheckLineStyles(Classificator const & c, string const & name)
UNIT_TEST(Classificator_DrawingRules)
{
UnitTestInitPlatform();
styles::RunForEveryMapStyle([](MapStyle)
{
Classificator const & c = classif();
@ -183,7 +167,6 @@ string CombineArrT(base::StringIL const & arrT)
void CheckPriority(vector<base::StringIL> const & arrT, vector<size_t> const & arrI, drule::rule_type_t ruleType)
{
UnitTestInitPlatform();
Classificator const & c = classif();
vector<vector<uint32_t> > types;
vector<vector<string> > typesInfo;
@ -275,3 +258,4 @@ UNIT_TEST(Classificator_PoiPriority)
}, {2, 5}, drule::symbol);
}
}
} // namespace classificator_tests

View file

@ -22,16 +22,6 @@ using namespace std;
namespace style_symbols_consistency_tests
{
void UnitTestInitPlatform()
{
Platform & pl = GetPlatform();
CommandLineOptions const & options = GetTestingOptions();
if (options.m_dataPath)
pl.SetWritableDirForTests(options.m_dataPath);
if (options.m_resourcePath)
pl.SetResourceDir(options.m_resourcePath);
}
class SdfParsingDispatcher
{
public:
@ -74,12 +64,9 @@ set<string> GetSymbolsSetFromResourcesFile(string const & density)
return symbols;
}
// Tests that all symbols specified in drawing rules have corresponding symbols in resources
UNIT_TEST(Test_SymbolsConsistency)
{
UnitTestInitPlatform();
// Tests that all symbols specified in drawing rules have corresponding symbols in resources
bool res = true;
string const densities[] = { "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi", "6plus" };

View file

@ -12,14 +12,13 @@
#include "base/timer.hpp"
using feature::DataHeader;
namespace platform
{
namespace tests_support
{
ScopedMwm::ScopedMwm(std::string const & relativePath) : m_file(relativePath, ScopedFile::Mode::Create)
{
DataHeader header;
feature::DataHeader header;
{
FilesContainerW container(m_file.GetFullPath());

View file

@ -6,7 +6,8 @@
#include "indexer/classificator_loader.hpp"
#include "platform/local_country_file_utils.cpp"
#include "platform/local_country_file.hpp"
#include "platform/local_country_file_utils.hpp"
#include "coding/write_to_sink.hpp"
@ -98,7 +99,7 @@ RoutesBuilder::RoutesBuilder(size_t threadsNumber) : m_threadPool(threadsNumber)
CHECK(m_cpg, ());
classificator::Load();
vector<platform::LocalCountryFile> localFiles;
std::vector<platform::LocalCountryFile> localFiles;
platform::FindAllLocalMapsAndCleanup(std::numeric_limits<int64_t>::max(), localFiles);
std::vector<std::unique_ptr<FrozenDataSource>> dataSources;
@ -261,7 +262,7 @@ void RoutesBuilder::Processor::InitRouter(VehicleType type)
return cigSharedPtr->GetRegionCountryId(pt);
};
auto const getMwmRectByName = [cig](string const & countryId) {
auto const getMwmRectByName = [cig](std::string const & countryId) {
auto const cigSharedPtr = cig.lock();
return cigSharedPtr->GetLimitRectForLeaf(countryId);
};

View file

@ -18,6 +18,8 @@
#include "gflags/gflags.h"
namespace testingmain
{
using namespace routing;
using namespace std;
using storage::CountryInfo;
@ -27,7 +29,7 @@ double constexpr kRouteLengthAccuracy = 0.15;
// Testing stub to make routing test tools linkable.
static CommandLineOptions g_options;
CommandLineOptions const & GetTestingOptions() {return g_options;}
CommandLineOptions const & GetTestingOptions() { return g_options; }
DEFINE_string(input_file, "", "File with statistics output.");
DEFINE_string(data_path, "../../data/", "Working directory, 'path_to_exe/../../data' if empty.");
@ -175,7 +177,7 @@ void ReadInput(istream & stream, RouteTester & tester)
tester.PrintStatistics();
}
int main(int argc, char ** argv)
int RunRoutingConsistencyTests(int argc, char ** argv)
{
gflags::SetUsageMessage("Check mwm and routing files consistency. Calculating roads from a user statistics.");
@ -192,3 +194,6 @@ int main(int argc, char ** argv)
return 0;
}
} // namespace testingmain
int main(int argc, char ** argv) { return ::testingmain::RunRoutingConsistencyTests(argc, argv); }

View file

@ -118,14 +118,6 @@ unique_ptr<IndexRouter> CreateVehicleRouter(DataSource & dataSource,
void GetAllLocalFiles(vector<LocalCountryFile> & localFiles)
{
// Setting stored paths from testingmain.cpp
Platform & pl = GetPlatform();
CommandLineOptions const & options = GetTestingOptions();
if (options.m_dataPath)
pl.SetWritableDirForTests(options.m_dataPath);
if (options.m_resourcePath)
pl.SetResourceDir(options.m_resourcePath);
platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max() /* latestVersion */,
localFiles);
for (auto & file : localFiles)

View file

@ -167,6 +167,8 @@ public:
std::shared_ptr<Route> GetRouteForTests() const { return m_route; }
double GetCompletionPercent() const;
private:
struct DoReadyCallback
{
@ -185,7 +187,6 @@ private:
void RemoveRoute();
void RebuildRouteOnTrafficUpdate();
double GetCompletionPercent() const;
void PassCheckpoints();
private:

View file

@ -19,12 +19,12 @@
#include <string>
#include <vector>
namespace async_router_test
{
using namespace routing;
using namespace std::placeholders;
using namespace std;
namespace
{
class DummyRouter : public IRouter
{
RouterResultCode m_result;
@ -32,7 +32,7 @@ class DummyRouter : public IRouter
public:
DummyRouter(RouterResultCode code, set<string> const & absent) : m_result(code), m_absent(absent) {}
// IRouter overrides:
string GetName() const override { return "Dummy"; }
void SetGuides(GuidesTracks && /* guides */) override {}
@ -146,4 +146,4 @@ struct DummyRoutingCallbacks
// TEST_EQUAL(resultCallback.m_absent.size(), 1, ());
// TEST(resultCallback.m_absent[0].empty(), ());
//}
} // namespace
} // namespace async_router_test

View file

@ -15,12 +15,10 @@
#include "3party/opening_hours/opening_hours.hpp"
using namespace std;
namespace routing_test
{
namespace
{
using namespace std;
double constexpr kEpsilon = 1e-6;
template <typename Graph>
@ -39,7 +37,6 @@ void AddGraph(unordered_map<NumMwmId, unique_ptr<Graph>> & graphs, NumMwmId mwmI
CHECK(it == graphs.end(), ("Already contains graph for mwm", mwmId));
graphs[mwmId] = move(graph);
}
} // namespace
// RestrictionTest ---------------------------------------------------------------------------------
void RestrictionTest::SetStarter(FakeEnding const & start, FakeEnding const & finish)

View file

@ -7,7 +7,7 @@
#include "base/math.hpp"
namespace
namespace position_accumulator_tests
{
using namespace routing;
@ -82,4 +82,4 @@ UNIT_CLASS_TEST(PositionAccumulator, LongSegment)
TEST_EQUAL(GetPointsForTesting().size(), 1, ());
TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0, 0.0), kEps), (GetDirection()));
}
} // namespace
} // namespace position_accumulator_tests

View file

@ -15,11 +15,11 @@
#include <utility>
#include <vector>
namespace routing_test
namespace restriction_test
{
using namespace std;
using namespace routing;
using routing::TestRestrictions;
using routing_test::TestRestrictions;
using Algorithm = AStarAlgorithm<Segment, SegmentEdge, RouteWeight>;
@ -1085,4 +1085,4 @@ UNIT_CLASS_TEST(RestrictionTest, RestrictionOnlyWithWayAsVia_1)
test({start, {0, 0}, {1, 0}, {2, 0}, {2, 1}, {3, 1}, finish}, std::move(restrictionsNo));
test({start, {0, 0}, {1, 0}, {2, 0}, {3, 1}, finish}, RestrictionVec());
}
} // namespace routing_test
} // namespace restriction_test

View file

@ -16,12 +16,12 @@
#include <string>
#include <vector>
namespace route_tests
{
using namespace routing;
using namespace routing::turns;
using namespace std;
namespace
{
static vector<m2::PointD> const kTestGeometry({{0, 0}, {0,1}, {1,1}, {1,2}, {1,3}});
static vector<Segment> const kTestSegments(
{{0, 0, 0, true}, {0, 0, 1, true}, {0, 0, 2, true}, {0, 0, 3, true}});
@ -87,7 +87,6 @@ std::vector<vector<Segment>> GetSegments()
{kFakeNumMwmId, 0, 0, true}, {0, 0, 1, true}, {0, 0, 2, true}, {kFakeNumMwmId, 0, 3, true}};
return {segmentsAllReal, segmentsFakeHeadAndTail, segmentsAllFake};
}
} // namespace
UNIT_TEST(AddAbsentCountryToRouteTest)
{
@ -373,3 +372,4 @@ UNIT_TEST(RouteNameTest)
route.GetCurrentStreetName(name);
TEST_EQUAL(name, "Street2", ());
}
} // namespace route_tests

View file

@ -20,7 +20,7 @@
#include <string>
#include <vector>
namespace
namespace routing_session_test
{
using namespace routing;
using namespace std;
@ -232,10 +232,7 @@ void TestLeavingRoute(RoutingSession & session, location::GpsInfo const & info)
session);
TestMovingByUpdatingLat(sessionStateTest, latitudes, info, session);
}
} // namespace
namespace routing
{
UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteBuilding)
{
// Multithreading synchronization note. |counter| and |session| are constructed on the main thread,
@ -640,4 +637,4 @@ UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteRebuildingError)
TestMovingByUpdatingLat(sessionStateTest, latitudes, info, *m_session);
}
}
} // namespace routing
} // namespace routing_session_test

View file

@ -7,21 +7,14 @@
#include <vector>
using namespace std;
namespace
{
// A error to compare two double after conversion feet to meters.
double const kEps = 1.;
} // namespace
namespace routing
{
namespace turns
{
namespace sound
namespace turns_sound_test
{
using namespace location;
using namespace routing::turns::sound;
using namespace std;
// An error to compare two double after conversion feet to meters.
double const kEps = 1.;
UNIT_TEST(TurnNotificationSettingsMetersTest)
{
@ -531,6 +524,4 @@ UNIT_TEST(GetJsonBufferTest)
TEST(GetJsonBuffer(platform::TextSource::TtsSound, localeNameRu, jsonBuffer), ());
TEST(!jsonBuffer.empty(), ());
}
} // namespace sound
} // namespace turns
} // namespace routing
} // namespace turns_sound_test

View file

@ -5,7 +5,7 @@
#include "routing/routing_tests/index_graph_tools.hpp"
#include "routing/routing_tests/world_graph_builder.hpp"
namespace routing_test
namespace uturn_restriction_tests
{
using namespace routing;
@ -137,4 +137,4 @@ UNIT_CLASS_TEST(NoUTurnRestrictionTest, CheckOnlyUTurn_2)
TestRouteGeom(start, finish, Algorithm::Result::OK, expectedGeomAfterRestriction);
}
} // namespace routing_test
} // namespace uturn_restriction_tests

View file

@ -55,7 +55,9 @@ class Settings
std::vector<uint32_t> m_soundedDistancesUnits;
measurement_utils::Units m_lengthUnits;
public:
// This constructor is for testing only.
// TODO: Do not compile it for production. Either use a static method or derive it in tests.
Settings(uint32_t notificationTimeSeconds, uint32_t minNotificationDistanceUnits,
uint32_t maxNotificationDistanceUnits, uint32_t startBeforeSeconds,
uint32_t minStartBeforeMeters, uint32_t maxStartBeforeMeters,
@ -75,7 +77,6 @@ class Settings
ASSERT(!m_soundedDistancesUnits.empty(), ());
}
public:
Settings(uint32_t startBeforeSecondsVehicle, uint32_t minStartBeforeMetersVehicle,
uint32_t maxStartBeforeMetersVehicle, uint32_t minDistToSayNotificationMeters,
uint32_t startBeforeSecondsPedestrian, uint32_t minStartBeforeMetersPedestrian,

View file

@ -16,11 +16,11 @@
#include <cstdint>
#include <vector>
namespace vehicle_model_test
{
using namespace routing;
using namespace std;
namespace
{
HighwayBasedSpeeds const kDefaultSpeeds = {
{HighwayType::HighwayTrunk, InOutCitySpeedKMpH(100.0 /* in city */, 150.0 /* out city */)},
{HighwayType::HighwayPrimary, InOutCitySpeedKMpH(90.0 /* in city */, 120.0 /* out city */)},
@ -129,7 +129,7 @@ void CheckPassThroughAllowed(initializer_list<uint32_t> const & types, bool expe
TEST_EQUAL(vehicleModel.HasPassThroughType(h), expectedValue, ());
}
} // namespace
UNIT_CLASS_TEST(VehicleModelTest, VehicleModel_MaxSpeed)
{
@ -288,3 +288,4 @@ UNIT_TEST(VehicleModel_CarModelValidation)
TEST(speedIt->second.IsValid(), (hwType, speedIt->second));
}
}
} // namespace vehicle_model_test

View file

@ -477,7 +477,7 @@ UNIT_TEST(HS_MWMSearch)
p.x = mercator::XToLon(p.x);
p.y = mercator::YToLat(p.y);
//double const eps = 3.0E-4;
//double constexpr eps = 3.0E-4;
//if (fabs(p.x - a.m_lon) < eps && fabs(p.y - a.m_lat) < eps)
if (ms::DistanceOnEarth(a.m_lat, a.m_lon, p.y, p.x) < 3.0)
{

View file

@ -11,13 +11,13 @@
#include <set>
#include <vector>
namespace segment_tree_tests
{
using namespace search;
using namespace std;
using Segment = SegmentTree::Segment;
namespace
{
auto const kInvalidId = numeric_limits<size_t>::max();
size_t FindAny(SegmentTree const & tree, double x)
@ -89,4 +89,4 @@ UNIT_TEST(SegmentTree_Simple)
TEST_EQUAL((set<size_t>{2}), FindAll(tree, -5.5), ());
TEST_EQUAL((set<size_t>{2, 3}), FindAll(tree, -5), ());
}
} // namespace
} // namespace segment_tree_tests

View file

@ -25,6 +25,8 @@
#include <boost/iterator/transform_iterator.hpp>
namespace text_index_tests
{
using namespace platform::tests_support;
using namespace search_base;
using namespace search;
@ -32,8 +34,6 @@ using namespace std;
using boost::make_transform_iterator;
namespace
{
// Prepend several bytes to serialized indexes in order to check the relative offsets.
size_t const kSkip = 10;
@ -77,13 +77,10 @@ void TestForEach(Index const & index, Token const & token, vector<uint32_t> cons
index.ForEachPosting(token, base::MakeBackInsertFunctor(actual));
TEST_EQUAL(actual, expected, (token));
};
} // namespace
namespace search
{
UNIT_TEST(TextIndex_Smoke)
{
vector<Token> const docsCollection = {
vector<search_base::Token> const docsCollection = {
"a b c",
"a c",
};
@ -152,12 +149,12 @@ UNIT_TEST(TextIndex_UniString)
UNIT_TEST(TextIndex_Merging)
{
// todo(@m) Arrays? docsCollection[i]
vector<Token> const docsCollection1 = {
vector<search_base::Token> const docsCollection1 = {
"a b c",
"",
"d",
};
vector<Token> const docsCollection2 = {
vector<search_base::Token> const docsCollection2 = {
"",
"a c",
"e",
@ -202,4 +199,4 @@ UNIT_TEST(TextIndex_Merging)
TestForEach(textIndexReader3, "e", {2});
}
}
} // namespace search
} // namespace text_index_tests

View file

@ -15,4 +15,7 @@ set(
omim_add_library(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} editor_tests_support)
target_link_libraries(${PROJECT_NAME}
generator_tests_support
editor_tests_support
)

View file

@ -296,7 +296,7 @@ template <class TBase> class filter_screenpts_adapter : public TBase
}
static bool empty_scr_rect(m2::RectD const & r)
{
double const eps = 1.0;
double constexpr eps = 1.0;
return (r.SizeX() < eps && r.SizeY() < eps);
}

View file

@ -9,8 +9,9 @@
#include "platform/platform.hpp"
#include "platform/platform_tests_support/writable_dir_changer.hpp"
namespace download_calc_size_test
{
using namespace storage;
void InitStorage(Storage & storage, Storage::UpdateCallback const & didDownload,
Storage::ProgressFunction const & progress)
{
@ -42,7 +43,7 @@ UNIT_TEST(DownloadingTests_CalcOverallProgress)
TEST_EQUAL(baseProgress.m_bytesDownloaded, 0, ());
TEST_EQUAL(baseProgress.m_bytesTotal, 0, ());
for (auto const &country : kTestCountries)
{
baseProgress.m_bytesTotal += s.CountrySizeInBytes(country).second;
@ -52,10 +53,10 @@ UNIT_TEST(DownloadingTests_CalcOverallProgress)
downloader::Progress const & /* progress */) {
auto const currentProgress = s.GetOverallProgress(kTestCountries);
LOG_SHORT(LINFO, (id, "downloading progress:", currentProgress));
TEST_GREATER_OR_EQUAL(currentProgress.m_bytesDownloaded, baseProgress.m_bytesDownloaded, ());
baseProgress.m_bytesDownloaded = currentProgress.m_bytesDownloaded;
TEST_LESS_OR_EQUAL(currentProgress.m_bytesDownloaded, baseProgress.m_bytesTotal, ());
TEST_EQUAL(currentProgress.m_bytesTotal, baseProgress.m_bytesTotal, ());
};
@ -64,6 +65,7 @@ UNIT_TEST(DownloadingTests_CalcOverallProgress)
for (auto const & countryId : kTestCountries)
s.DownloadNode(countryId);
testing::RunEventLoop();
}
} // namespace download_calc_size_test

View file

@ -24,7 +24,9 @@ struct PointAndCountry
storage::CountryId m_country;
};
UNIT_CLASS_TEST(lightweight::CountryInfoReader, LightweightMatching)
using lightweight::CountryInfoReader;
UNIT_CLASS_TEST(CountryInfoReader, LightweightMatching)
{
auto const reader = storage::CountryInfoReader::CreateCountryInfoReader(GetPlatform());

View file

@ -17,12 +17,12 @@
#include <string>
namespace storage_group_download_tests
{
using namespace platform;
using namespace std;
using namespace storage;
namespace
{
CountryId const kGroupCountryId = "Venezuela";
CountriesSet const kLeafCountriesIds = { "Venezuela_North", "Venezuela_South" };
@ -272,8 +272,6 @@ void TestDownloadDelete(bool downloadOneByOne, bool deleteOneByOne)
DeleteGroup(storage, deleteOneByOne);
}
} // namespace
UNIT_TEST(SmallMwms_GroupDownloadDelete_Test1)
{
TestDownloadDelete(false, false);
@ -293,3 +291,4 @@ UNIT_TEST(SmallMwms_GroupDownloadDelete_Test4)
{
TestDownloadDelete(true, true);
}
} // namespace storage_group_download_tests

View file

@ -17,12 +17,12 @@
#include <string>
namespace storage_http_tests
{
using namespace platform;
using namespace std;
using namespace storage;
namespace
{
string const kCountryId = "Trinidad and Tobago";
string const kDisputedCountryId1 = "Jerusalem";
string const kDisputedCountryId2 = "Crimea";
@ -88,7 +88,6 @@ protected:
string const m_version;
tests_support::ScopedDir const m_cleanupVersionDir;
};
} // namespace
UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadNodeAndDeleteNode)
{
@ -183,3 +182,4 @@ UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadAndDeleteDisputedNode)
TEST(!platform.IsFileExistsByFullPath(mwmFullPath3), ());
TEST(!platform.IsFileExistsByFullPath(mwmFullPathUndisputed), ());
}
} // namespace storage_http_tests

View file

@ -19,12 +19,12 @@
#include <memory>
#include <string>
namespace storage_update_tests
{
using namespace platform;
using namespace std;
using namespace storage;
namespace
{
static FrameworkParams const kFrameworkParams(false /* m_enableDiffs */);
string const kCountriesTxtFile = COUNTRIES_FILE;
@ -37,10 +37,6 @@ string const kMwmVersion2 = "190910";
string const kGroupCountryId = "Belarus";
// TODO: Remove after uncommenting tests below.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
bool DownloadFile(string const & url,
string const & filePath,
size_t fileSize)
@ -82,8 +78,6 @@ string GetMwmFilePath(string const & version, CountryId const & countryId)
return base::JoinPath(GetPlatform().WritableDir(), version, countryId + DATA_FILE_EXTENSION);
}
} // namespace
/// @todo We don't have direct version links for now.
/// Also Framework f(kFrameworkParams) will fail here, @see SmallMwms_3levels_Test.
/*
@ -196,5 +190,4 @@ UNIT_TEST(SmallMwms_Update_Test)
}
}
*/
#pragma GCC diagnostic pop
} // namespace storage_update_tests

View file

@ -137,6 +137,17 @@ void ParseOptions(int argc, char * argv[], CommandLineOptions & options)
if (strcmp(arg, kListAllTestsOption) == 0)
options.m_listTests = true;
}
#ifndef OMIM_UNIT_TEST_DISABLE_PLATFORM_INIT
// Setting stored paths from testingmain.cpp
Platform & pl = GetPlatform();
if (options.m_dataPath)
pl.SetWritableDirForTests(options.m_dataPath);
if (options.m_resourcePath)
{
pl.SetResourceDir(options.m_resourcePath);
pl.SetSettingsDir(options.m_resourcePath);
}
#endif
}
CommandLineOptions const & GetTestingOptions()
@ -183,19 +194,6 @@ int main(int argc, char * argv[])
if (g_testingOptions.m_suppressRegExp)
suppressRegExp.assign(g_testingOptions.m_suppressRegExp);
#ifndef OMIM_UNIT_TEST_DISABLE_PLATFORM_INIT
// Setting stored paths from testingmain.cpp
Platform & pl = GetPlatform();
CommandLineOptions const & options = GetTestingOptions();
if (options.m_dataPath)
pl.SetWritableDirForTests(options.m_dataPath);
if (options.m_resourcePath)
{
pl.SetResourceDir(options.m_resourcePath);
pl.SetSettingsDir(options.m_resourcePath);
}
#endif
for (TestRegister * test = TestRegister::FirstRegister(); test; test = test->m_next)
{
string filename(test->m_filename);
@ -300,4 +298,4 @@ int main(int argc, char * argv[])
}
} // namespace testing
int main(int argc, char * argv[]) { return testing::main(argc, argv); }
int main(int argc, char * argv[]) { return ::testing::main(argc, argv); }

View file

@ -21,6 +21,7 @@ omim_add_library(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME}
generator
tracking
platform
)

View file

@ -337,7 +337,7 @@ void UpdateLinePart(LineParts & lineParts, LineSegment const & segment,
std::pair<LineSegments, LineSegments> FindIntersections(std::vector<m2::PointD> const & line1,
std::vector<m2::PointD> const & line2)
{
double const eps = 1e-5;
double constexpr eps = 1e-5;
size_t constexpr minIntersection = 2;
CHECK_GREATER_OR_EQUAL(line1.size(), minIntersection, ());

View file

@ -14,6 +14,13 @@
#include "3party/jansson/myjansson.hpp"
#include "3party/opening_hours/opening_hours.hpp"
namespace transit
{
std::string const kHashPrefix = "mapsme_transit";
std::string const kDefaultLang = "default";
std::string const kSubwayRouteType = "subway";
std::string const kDefaultHours = "24/7";
namespace
{
double constexpr kEps = 1e-5;
@ -60,12 +67,7 @@ void UpdateReversedSegmentIndexes(transit::LineSegment & segment, size_t polylin
}
} // namespace
namespace transit
{
std::string const kHashPrefix = "mapsme_transit";
std::string const kDefaultLang = "default";
std::string const kSubwayRouteType = "subway";
std::string const kDefaultHours = "24/7";
SubwayConverter::SubwayConverter(std::string const & subwayJson, WorldFeed & feed)
: m_subwayJson(subwayJson), m_feed(feed)

View file

@ -26,12 +26,9 @@ class WorldFeedIntegrationTests
{
public:
WorldFeedIntegrationTests()
: m_mwmMatcher(GetTestingOptions().m_resourcePath, false /* haveBordersForWholeWorld */)
: m_mwmMatcher(GetPlatform().ResourcesDir(), false /* haveBordersForWholeWorld */)
, m_globalFeed(m_generator, m_generatorEdges, m_colorPicker, m_mwmMatcher)
{
auto const & options = GetTestingOptions();
GetPlatform().SetResourceDir(options.m_resourcePath);
m_testPath = base::JoinPath(GetPlatform().WritableDir(), kFeedsSubdir);
CHECK(GetPlatform().IsFileExistsByFullPath(m_testPath), ());

View file

@ -35,11 +35,8 @@ class SubwayConverterTests
{
public:
SubwayConverterTests()
: m_mwmMatcher(GetTestingOptions().m_resourcePath, false /* haveBordersForWholeWorld */)
: m_mwmMatcher(GetPlatform().ResourcesDir(), false /* haveBordersForWholeWorld */)
{
auto const & options = GetTestingOptions();
GetPlatform().SetResourceDir(options.m_resourcePath);
CHECK(Platform::MkDirChecked(kSubwayTestsDir),
("Could not create directory for test data:", kSubwayTestsDir));
m_generator = transit::IdGenerator(base::JoinPath(kSubwayTestsDir, kMappingFile));

View file

@ -19,10 +19,10 @@
#include "3party/just_gtfs/just_gtfs.h"
#include "3party/opening_hours/opening_hours.hpp"
namespace world_feed_tests
{
using namespace transit;
namespace
{
std::vector<gtfs::CalendarAvailability> GetCalendarAvailability(std::vector<size_t> const & data)
{
CHECK_EQUAL(data.size(), 7, ());
@ -412,9 +412,6 @@ UNIT_TEST(Transit_GTFS_ProjectStopToLine_NearCircle)
UNIT_TEST(Transit_ColorPicker)
{
auto const & options = GetTestingOptions();
GetPlatform().SetResourceDir(options.m_resourcePath);
ColorPicker colorPicker;
// We check that we don't match with the 'text' colors subset. This is the color of transit
@ -571,4 +568,4 @@ UNIT_TEST(SplitLineToRegions)
TestStopsRange({1, 2, 3, 4, 5, 6, 7} /* stopsOnLine */, {3, 4} /* stopsInRegion */,
1 /* firstIdxPlan */, 4 /* lastIdxPlan */);
}
} // namespace
} // namespace world_feed_tests