Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -107,8 +107,8 @@ RoadAccessByVehicleType SaveAndLoadRoadAccess(
}
*/
OsmElement MakeOsmElementWithNodes(uint64_t id, generator_tests::Tags const & tags,
OsmElement::EntityType t, std::vector<uint64_t> const & nodes)
OsmElement MakeOsmElementWithNodes(uint64_t id, generator_tests::Tags const & tags, OsmElement::EntityType t,
std::vector<uint64_t> const & nodes)
{
auto r = generator_tests::MakeOsmElement(id, tags, t);
r.m_nodes = nodes;
@@ -133,13 +133,9 @@ public:
}
virtual bool GetRelation(cache::Key id, RelationElement & e) { UNREACHABLE(); }
void Add(OsmElement const & e)
{
TEST(m_map.try_emplace(e.m_id, e.m_id, e.m_nodes).second, ());
}
void Add(OsmElement const & e) { TEST(m_map.try_emplace(e.m_id, e.m_id, e.m_nodes).second, ()); }
};
/*
UNIT_TEST(RoadAccess_Smoke)
{
@@ -199,12 +195,12 @@ class TestAccessFixture
class Way2Feature : public OsmWay2FeaturePoint
{
public:
virtual void ForEachFeature(uint64_t wayID, std::function<void (uint32_t)> const & fn) override
virtual void ForEachFeature(uint64_t wayID, std::function<void(uint32_t)> const & fn) override
{
fn(base::checked_cast<uint32_t>(wayID));
}
virtual void ForEachNodeIdx(uint64_t wayID, uint32_t candidateIdx, m2::PointU pt,
std::function<void (uint32_t, uint32_t)> const & fn) override
std::function<void(uint32_t, uint32_t)> const & fn) override
{
auto const ll = mercator::ToLatLon(PointUToPointD(pt, kPointCoordBits, mercator::Bounds::FullRect()));
@@ -225,10 +221,7 @@ public:
{
classificator::Load();
}
~TestAccessFixture()
{
TEST(Platform::RemoveFileIfExists(m_fileName), ());
}
~TestAccessFixture() { TEST(Platform::RemoveFileIfExists(m_fileName), ()); }
void CreateCollectors(size_t count = 1)
{
@@ -272,17 +265,13 @@ public:
ReadRoadAccess(m_fileName, m_wya2feature, m_roadAccess);
}
RoadAccess const & Get(VehicleType vehicle) const
{
return m_roadAccess[static_cast<uint8_t>(vehicle)];
}
RoadAccess const & Get(VehicleType vehicle) const { return m_roadAccess[static_cast<uint8_t>(vehicle)]; }
};
UNIT_CLASS_TEST(TestAccessFixture, CarPermit)
{
CreateCollectors();
AddWay(MakeOsmElementWithNodes(1 /* id */,
{{"highway", "motorway"}, {"access", "no"}, {"motor_vehicle", "permit"}},
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "motorway"}, {"access", "no"}, {"motor_vehicle", "permit"}},
OsmElement::EntityType::Way, {1, 2}));
Finish();
@@ -299,13 +288,17 @@ UNIT_CLASS_TEST(TestAccessFixture, HgvDesignated)
{
CreateCollectors();
AddWay(MakeOsmElementWithNodes(1 /* id */,
{{"highway", "motorway"}, {"access", "no"}, {"emergency", "yes"},
{"bus", "yes"}, {"hgv", "designated"}, {"motor_vehicle", "yes"}},
{{"highway", "motorway"},
{"access", "no"},
{"emergency", "yes"},
{"bus", "yes"},
{"hgv", "designated"},
{"motor_vehicle", "yes"}},
OsmElement::EntityType::Way, {1, 2}));
AddWay(MakeOsmElementWithNodes(2 /* id */,
{{"highway", "motorway"}, {"access", "no"}, {"emergency", "yes"},
{"bus", "yes"}, {"hgv", "designated"}},
OsmElement::EntityType::Way, {2, 3}));
AddWay(MakeOsmElementWithNodes(
2 /* id */,
{{"highway", "motorway"}, {"access", "no"}, {"emergency", "yes"}, {"bus", "yes"}, {"hgv", "designated"}},
OsmElement::EntityType::Way, {2, 3}));
Finish();
auto const noSure = make_pair(RoadAccess::Type::No, RoadAccess::Confidence::Sure);
@@ -322,26 +315,31 @@ UNIT_CLASS_TEST(TestAccessFixture, Merge)
{
CreateCollectors(3);
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "service"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}), 0);
AddWay(MakeOsmElementWithNodes(2 /* id */, {{"highway", "service"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}), 1);
AddWay(MakeOsmElementWithNodes(3 /* id */, {{"highway", "motorway"}} /* tags */,
OsmElement::EntityType::Way, {30, 31, 32, 33}), 2);
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "service"}} /* tags */, OsmElement::EntityType::Way,
{10, 11, 12, 13}),
0);
AddWay(MakeOsmElementWithNodes(2 /* id */, {{"highway", "service"}} /* tags */, OsmElement::EntityType::Way,
{20, 21, 22, 23}),
1);
AddWay(MakeOsmElementWithNodes(3 /* id */, {{"highway", "motorway"}} /* tags */, OsmElement::EntityType::Way,
{30, 31, 32, 33}),
2);
AddNode(MakeOsmElement(11 /* id */, {{"barrier", "lift_gate"}, {"motor_vehicle", "private"}},
OsmElement::EntityType::Node), 0);
OsmElement::EntityType::Node),
0);
AddNode(MakeOsmElement(22 /* id */, {{"barrier", "lift_gate"}, {"motor_vehicle", "private"}},
OsmElement::EntityType::Node), 1);
OsmElement::EntityType::Node),
1);
// We should ignore this barrier because it's without access tag and placed on highway-motorway.
AddNode(MakeOsmElement(32 /* id */, {{"barrier", "lift_gate"}},
OsmElement::EntityType::Node), 2);
AddNode(MakeOsmElement(32 /* id */, {{"barrier", "lift_gate"}}, OsmElement::EntityType::Node), 2);
// Ignore all motorway_junction access.
AddNode(MakeOsmElement(31 /* id */, {{"highway", "motorway_junction"}, {"access", "private"}},
OsmElement::EntityType::Node), 0);
OsmElement::EntityType::Node),
0);
Finish();
@@ -361,23 +359,17 @@ UNIT_TEST(RoadAccessCoditional_Parse)
using ConditionalVector = std::vector<AccessConditional>;
std::vector<std::pair<string, ConditionalVector>> const tests = {
{"no @ Mo-Su",
{{RoadAccess::Type::No, "Mo-Su"}}},
{"no @ Mo-Su", {{RoadAccess::Type::No, "Mo-Su"}}},
{"no @ Mo-Su;",
{{RoadAccess::Type::No, "Mo-Su"}}},
{"no @ Mo-Su;", {{RoadAccess::Type::No, "Mo-Su"}}},
{"yes @ (10:00 - 20:00)",
{{RoadAccess::Type::Yes, "10:00 - 20:00"}}},
{"yes @ (10:00 - 20:00)", {{RoadAccess::Type::Yes, "10:00 - 20:00"}}},
{"private @ Mo-Fr 15:00-20:00",
{{RoadAccess::Type::Private, "Mo-Fr 15:00-20:00"}}},
{"private @ Mo-Fr 15:00-20:00", {{RoadAccess::Type::Private, "Mo-Fr 15:00-20:00"}}},
{"destination @ 10:00-20:00",
{{RoadAccess::Type::Destination, "10:00-20:00"}}},
{"destination @ 10:00-20:00", {{RoadAccess::Type::Destination, "10:00-20:00"}}},
{"yes @ Mo-Fr ; Sa-Su",
{{RoadAccess::Type::Yes, "Mo-Fr ; Sa-Su"}}},
{"yes @ Mo-Fr ; Sa-Su", {{RoadAccess::Type::Yes, "Mo-Fr ; Sa-Su"}}},
{"no @ (Mo-Su) ; yes @ (Fr-Su)",
{{RoadAccess::Type::No, "Mo-Su"},
@@ -386,23 +378,19 @@ UNIT_TEST(RoadAccessCoditional_Parse)
{"private @ (18:00-09:00; Oct-Mar)", {{RoadAccess::Type::Private, "18:00-09:00; Oct-Mar"}}},
{"no @ (Nov-May); no @ (20:00-07:00)",
{{RoadAccess::Type::No, "Nov-May"},
{RoadAccess::Type::No, "20:00-07:00"}}},
{{RoadAccess::Type::No, "Nov-May"}, {RoadAccess::Type::No, "20:00-07:00"}}},
{"no @ 22:30-05:00",
{{RoadAccess::Type::No, "22:30-05:00"}}},
{"no @ 22:30-05:00", {{RoadAccess::Type::No, "22:30-05:00"}}},
{"destination @ (Mo-Fr 06:00-15:00); yes @ (Mo-Fr 15:00-21:00; Sa,Su,SH,PH 09:00-21:00)",
{{RoadAccess::Type::Destination, "Mo-Fr 06:00-15:00"},
{RoadAccess::Type::Yes, "Mo-Fr 15:00-21:00; Sa,Su,SH,PH 09:00-21:00"}}},
{"no @ (Mar 15-Jul 15); private @ (Jan- Dec)",
{{RoadAccess::Type::No, "Mar 15-Jul 15"},
{RoadAccess::Type::Private, "Jan- Dec"}}},
{{RoadAccess::Type::No, "Mar 15-Jul 15"}, {RoadAccess::Type::Private, "Jan- Dec"}}},
{"no @ (06:30-08:30);destination @ (06:30-08:30 AND agricultural)",
{{RoadAccess::Type::No, "06:30-08:30"},
{RoadAccess::Type::Destination, "06:30-08:30 AND agricultural"}}},
{{RoadAccess::Type::No, "06:30-08:30"}, {RoadAccess::Type::Destination, "06:30-08:30 AND agricultural"}}},
{"no @ (Mo-Fr 00:00-08:00,20:00-24:00; Sa-Su 00:00-24:00; PH 00:00-24:00)",
{{RoadAccess::Type::No, "Mo-Fr 00:00-08:00,20:00-24:00; Sa-Su 00:00-24:00; PH 00:00-24:00"}}},
@@ -412,16 +400,10 @@ UNIT_TEST(RoadAccessCoditional_Parse)
{"yes Mo-Fr", {}},
{"yes (Mo-Fr)", {}},
{"no ; Mo-Fr", {}},
{"asdsadasdasd", {}}
};
{"asdsadasdasd", {}}};
std::vector<string> tags = {
"motorcar:conditional",
"vehicle:conditional",
"motor_vehicle:conditional",
"bicycle:conditional",
"foot:conditional"
};
std::vector<string> tags = {"motorcar:conditional", "vehicle:conditional", "motor_vehicle:conditional",
"bicycle:conditional", "foot:conditional"};
for (auto const & tag : tags)
{
@@ -451,20 +433,21 @@ UNIT_CLASS_TEST(TestAccessFixture, ConditionalMerge)
{
CreateCollectors(3);
AddWay(MakeOsmElementWithNodes(
1 /* id */, {{"highway", "primary"}, {"vehicle:conditional", "no @ (Mo-Su)"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}), 0);
AddWay(
MakeOsmElementWithNodes(1 /* id */, {{"highway", "primary"}, {"vehicle:conditional", "no @ (Mo-Su)"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}),
0);
AddWay(MakeOsmElementWithNodes(
2 /* id */,
{{"highway", "service"}, {"vehicle:conditional", "private @ (10:00-20:00)"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}), 1);
2 /* id */, {{"highway", "service"}, {"vehicle:conditional", "private @ (10:00-20:00)"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}),
1);
AddWay(MakeOsmElementWithNodes(
3 /* id */,
{{"highway", "service"},
{"vehicle:conditional", "private @ (12:00-19:00) ; no @ (Mo-Su)"}} /* tags */,
OsmElement::EntityType::Way, {30, 31, 32, 33}), 2);
3 /* id */,
{{"highway", "service"}, {"vehicle:conditional", "private @ (12:00-19:00) ; no @ (Mo-Su)"}} /* tags */,
OsmElement::EntityType::Way, {30, 31, 32, 33}),
2);
Finish();
@@ -483,18 +466,15 @@ UNIT_CLASS_TEST(TestAccessFixture, WinterRoads)
{
CreateCollectors();
AddWay(MakeOsmElementWithNodes(
1 /* id */, {{"highway", "primary"}, {"ice_road", "yes"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}));
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "primary"}, {"ice_road", "yes"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}));
AddWay(MakeOsmElementWithNodes(
2 /* id */,
{{"highway", "service"}, {"winter_road", "yes"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}));
AddWay(MakeOsmElementWithNodes(2 /* id */, {{"highway", "service"}, {"winter_road", "yes"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}));
Finish();
for (auto vehicle : { VehicleType::Pedestrian, VehicleType::Bicycle, VehicleType::Car })
for (auto vehicle : {VehicleType::Pedestrian, VehicleType::Bicycle, VehicleType::Car})
{
auto const & ra = Get(vehicle);
for (uint64_t id = 1; id <= 2; ++id)
@@ -514,13 +494,12 @@ UNIT_CLASS_TEST(TestAccessFixture, Locked)
{
CreateCollectors();
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "service"}} /* tags */,
OsmElement::EntityType::Way, {10, 11, 12, 13}));
AddWay(MakeOsmElementWithNodes(2 /* id */, {{"highway", "secondary"}} /* tags */,
OsmElement::EntityType::Way, {20, 21, 22, 23}));
AddWay(MakeOsmElementWithNodes(1 /* id */, {{"highway", "service"}} /* tags */, OsmElement::EntityType::Way,
{10, 11, 12, 13}));
AddWay(MakeOsmElementWithNodes(2 /* id */, {{"highway", "secondary"}} /* tags */, OsmElement::EntityType::Way,
{20, 21, 22, 23}));
AddNode(MakeOsmElement(11 /* id */, {{"barrier", "gate"}, {"locked", "yes"}},
OsmElement::EntityType::Node));
AddNode(MakeOsmElement(11 /* id */, {{"barrier", "gate"}, {"locked", "yes"}}, OsmElement::EntityType::Node));
AddNode(MakeOsmElement(21 /* id */, {{"barrier", "gate"}, {"locked", "yes"}, {"access", "permissive"}},
OsmElement::EntityType::Node));
@@ -541,22 +520,18 @@ UNIT_CLASS_TEST(TestAccessFixture, CycleBarrier)
{
CreateCollectors();
AddWay(MakeOsmElementWithNodes(1, {{"highway", "track"}},
OsmElement::EntityType::Way, {10, 11, 12}));
AddNode(MakeOsmElement(10, {{"barrier", "cycle_barrier"}},
OsmElement::EntityType::Node));
AddNode(MakeOsmElement(11, {{"barrier", "cycle_barrier"}, {"bicycle", "dismount"}},
OsmElement::EntityType::Node));
AddNode(MakeOsmElement(12, {{"barrier", "cycle_barrier"}, {"bicycle", "no"}},
OsmElement::EntityType::Node));
AddWay(MakeOsmElementWithNodes(1, {{"highway", "track"}}, OsmElement::EntityType::Way, {10, 11, 12}));
AddNode(MakeOsmElement(10, {{"barrier", "cycle_barrier"}}, OsmElement::EntityType::Node));
AddNode(MakeOsmElement(11, {{"barrier", "cycle_barrier"}, {"bicycle", "dismount"}}, OsmElement::EntityType::Node));
AddNode(MakeOsmElement(12, {{"barrier", "cycle_barrier"}, {"bicycle", "no"}}, OsmElement::EntityType::Node));
Finish();
auto const bicycle = Get(VehicleType::Bicycle);
TEST_EQUAL(bicycle.GetAccessWithoutConditional({1, 0}),
make_pair(RoadAccess::Type::Yes, RoadAccess::Confidence::Sure), ());
TEST_EQUAL(bicycle.GetAccessWithoutConditional({1, 1}),
make_pair(RoadAccess::Type::Yes, RoadAccess::Confidence::Sure), ());
TEST_EQUAL(bicycle.GetAccessWithoutConditional({1, 2}),
make_pair(RoadAccess::Type::No, RoadAccess::Confidence::Sure), ());
TEST_EQUAL(bicycle.GetAccessWithoutConditional({1, 2}), make_pair(RoadAccess::Type::No, RoadAccess::Confidence::Sure),
());
}
} // namespace road_access_test