mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 22:53:43 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -75,8 +75,8 @@ std::unique_ptr<IndexGraph> BuildTwoCubeGraph()
|
||||
|
||||
std::vector<Joint> const joints = {
|
||||
// {{/* feature id */, /* point id */}, ... }
|
||||
MakeJoint({{7, 0}}), /* joint at point (-1, 0) */
|
||||
MakeJoint({{0, 0}, {6, 0}, {7, 1}}), /* joint at point (0, 0) */
|
||||
MakeJoint({{7, 0}}), /* joint at point (-1, 0) */
|
||||
MakeJoint({{0, 0}, {6, 0}, {7, 1}}), /* joint at point (0, 0) */
|
||||
MakeJoint({{0, 1}, {1, 0}}), /* joint at point (1, 0) */
|
||||
MakeJoint({{1, 1}, {2, 0}, {9, 0}}), /* joint at point (2, 0) */
|
||||
MakeJoint({{2, 1}, {3, 1}, {8, 0}}), /* joint at point (2, 1) */
|
||||
@@ -120,9 +120,7 @@ RelationElement MakeRelationElement(std::vector<RelationElement::Member> const &
|
||||
class TestRestrictionCollector
|
||||
{
|
||||
public:
|
||||
|
||||
TestRestrictionCollector()
|
||||
: m_scopedDir(kTestDir)
|
||||
TestRestrictionCollector() : m_scopedDir(kTestDir)
|
||||
{
|
||||
// Creating osm ids to feature ids mapping.
|
||||
std::string const mappingRelativePath = base::JoinPath(kTestDir, kOsmIdsToFeatureIdsName);
|
||||
@@ -130,8 +128,7 @@ public:
|
||||
m_scopedFile = std::make_shared<ScopedFile>(mappingRelativePath, ScopedFile::Mode::Create);
|
||||
m_osmIdsToFeatureIdFullPath = m_scopedFile->GetFullPath();
|
||||
|
||||
ReEncodeOsmIdsToFeatureIdsMapping(kosmIdsToFeatureIdsContentForTwoCubeGraph,
|
||||
m_osmIdsToFeatureIdFullPath);
|
||||
ReEncodeOsmIdsToFeatureIdsMapping(kosmIdsToFeatureIdsContentForTwoCubeGraph, m_osmIdsToFeatureIdFullPath);
|
||||
}
|
||||
|
||||
void ValidCase()
|
||||
@@ -141,19 +138,21 @@ public:
|
||||
|
||||
// Adding restrictions.
|
||||
TEST(restrictionCollector.AddRestriction(
|
||||
{2.0, 0.0} /* coords of intersection feature with id = 1 and feature with id = 2 */,
|
||||
Restriction::Type::No, /* restriction type */
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2)} /* features in format {from, (via*)?, to} */
|
||||
), ());
|
||||
{2.0, 0.0} /* coords of intersection feature with id = 1 and feature with id = 2 */,
|
||||
Restriction::Type::No, /* restriction type */
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2)} /* features in format {from, (via*)?, to} */
|
||||
),
|
||||
());
|
||||
|
||||
TEST(restrictionCollector.AddRestriction({2.0, 1.0}, Restriction::Type::Only,
|
||||
{base::MakeOsmWay(2), base::MakeOsmWay(3)}), ());
|
||||
{base::MakeOsmWay(2), base::MakeOsmWay(3)}),
|
||||
());
|
||||
|
||||
TEST(restrictionCollector.AddRestriction(
|
||||
RestrictionCollector::kNoCoords, /* no coords in case of way as via */
|
||||
Restriction::Type::No,
|
||||
/* from via to */
|
||||
{base::MakeOsmWay(0), base::MakeOsmWay(1), base::MakeOsmWay(2)}), ());
|
||||
TEST(restrictionCollector.AddRestriction(RestrictionCollector::kNoCoords, /* no coords in case of way as via */
|
||||
Restriction::Type::No,
|
||||
/* from via to */
|
||||
{base::MakeOsmWay(0), base::MakeOsmWay(1), base::MakeOsmWay(2)}),
|
||||
());
|
||||
|
||||
base::SortUnique(restrictionCollector.m_restrictions);
|
||||
|
||||
@@ -175,7 +174,8 @@ public:
|
||||
|
||||
// No such feature - 2809
|
||||
TEST(!restrictionCollector.AddRestriction({2.0, 1.0}, Restriction::Type::No,
|
||||
{base::MakeOsmWay(2809), base::MakeOsmWay(1)}), ());
|
||||
{base::MakeOsmWay(2809), base::MakeOsmWay(1)}),
|
||||
());
|
||||
|
||||
TEST(!restrictionCollector.HasRestrictions(), ());
|
||||
}
|
||||
@@ -187,14 +187,14 @@ public:
|
||||
|
||||
// Fetures with id 1 and 2 do not intersect in {2.0, 1.0}
|
||||
TEST(!restrictionCollector.AddRestriction({2.0, 1.0}, Restriction::Type::No,
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2)}), ());
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2)}),
|
||||
());
|
||||
|
||||
// No such chain of features (1 => 2 => 4),
|
||||
// because feature with id 2 and 4 do not have common joint.
|
||||
TEST(!restrictionCollector.AddRestriction(
|
||||
RestrictionCollector::kNoCoords,
|
||||
Restriction::Type::No,
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2), base::MakeOsmWay(4)}), ());
|
||||
TEST(!restrictionCollector.AddRestriction(RestrictionCollector::kNoCoords, Restriction::Type::No,
|
||||
{base::MakeOsmWay(1), base::MakeOsmWay(2), base::MakeOsmWay(4)}),
|
||||
());
|
||||
|
||||
TEST(!restrictionCollector.HasRestrictions(), ());
|
||||
}
|
||||
@@ -205,7 +205,6 @@ private:
|
||||
std::string m_osmIdsToFeatureIdFullPath;
|
||||
};
|
||||
|
||||
|
||||
UNIT_CLASS_TEST(TestRestrictionCollector, ValidCase)
|
||||
{
|
||||
TestRestrictionCollector::ValidCase();
|
||||
@@ -230,11 +229,15 @@ UNIT_TEST(RestrictionWriter_Merge)
|
||||
auto c1 = std::make_shared<RestrictionWriter>(filename, nullptr /* cache */);
|
||||
auto c2 = c1->Clone();
|
||||
std::map<std::string, std::string, std::less<>> const tags = {{"type", "restriction"},
|
||||
{"restriction", "no_right_turn"}};
|
||||
c1->CollectRelation(MakeRelationElement({} /* nodes */, {{1, "via"}, {11, "from"}, {21, "to"}} /* ways */, tags /* tags */));
|
||||
c2->CollectRelation(MakeRelationElement({} /* nodes */, {{2, "via"}, {12, "from"}, {22, "to"}} /* ways */, tags /* tags */));
|
||||
c1->CollectRelation(MakeRelationElement({} /* nodes */, {{3, "via"}, {13, "from"}, {23, "to"}} /* ways */, tags /* tags */));
|
||||
c2->CollectRelation(MakeRelationElement({} /* nodes */, {{4, "via"}, {14, "from"}, {24, "to"}} /* ways */, tags /* tags */));
|
||||
{"restriction", "no_right_turn"}};
|
||||
c1->CollectRelation(
|
||||
MakeRelationElement({} /* nodes */, {{1, "via"}, {11, "from"}, {21, "to"}} /* ways */, tags /* tags */));
|
||||
c2->CollectRelation(
|
||||
MakeRelationElement({} /* nodes */, {{2, "via"}, {12, "from"}, {22, "to"}} /* ways */, tags /* tags */));
|
||||
c1->CollectRelation(
|
||||
MakeRelationElement({} /* nodes */, {{3, "via"}, {13, "from"}, {23, "to"}} /* ways */, tags /* tags */));
|
||||
c2->CollectRelation(
|
||||
MakeRelationElement({} /* nodes */, {{4, "via"}, {14, "from"}, {24, "to"}} /* ways */, tags /* tags */));
|
||||
c1->Finish();
|
||||
c2->Finish();
|
||||
c1->Merge(*c2);
|
||||
@@ -246,10 +249,11 @@ UNIT_TEST(RestrictionWriter_Merge)
|
||||
std::stringstream buffer;
|
||||
buffer << stream.rdbuf();
|
||||
|
||||
std::string const correctAnswer = "No,way,11,1,21\n"
|
||||
"No,way,13,3,23\n"
|
||||
"No,way,12,2,22\n"
|
||||
"No,way,14,4,24\n";
|
||||
std::string const correctAnswer =
|
||||
"No,way,11,1,21\n"
|
||||
"No,way,13,3,23\n"
|
||||
"No,way,12,2,22\n"
|
||||
"No,way,14,4,24\n";
|
||||
TEST_EQUAL(buffer.str(), correctAnswer, ());
|
||||
}
|
||||
} // namespace routing_builder
|
||||
|
||||
Reference in New Issue
Block a user