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

@@ -11,11 +11,11 @@ namespace algorithm_test
{
using namespace std;
using m2::CalculateBoundingBox;
using m2::CalculatePointOnSurface;
using m2::CalculatePolyLineCenter;
using m2::PointD;
using m2::RectD;
using m2::CalculatePolyLineCenter;
using m2::CalculatePointOnSurface;
using m2::CalculateBoundingBox;
PointD GetPolyLineCenter(vector<PointD> const & points)
{
@@ -42,52 +42,28 @@ bool PointsAlmostEqual(PointD const & p1, PointD const & p2)
UNIT_TEST(CalculatePolyLineCenter)
{
{
vector<PointD> const points {
{0, 0},
{1, 1},
{2, 2}
};
vector<PointD> const points{{0, 0}, {1, 1}, {2, 2}};
TEST_EQUAL(GetPolyLineCenter(points), PointD(1, 1), ());
}
{
vector<PointD> const points {
{0, 2},
{1, 1},
{2, 2}
};
vector<PointD> const points{{0, 2}, {1, 1}, {2, 2}};
TEST_EQUAL(GetPolyLineCenter(points), PointD(1, 1), ());
}
{
vector<PointD> const points {
{1, 1},
{2, 2},
{4, 4},
vector<PointD> const points{
{1, 1},
{2, 2},
{4, 4},
};
TEST_EQUAL(GetPolyLineCenter(points), PointD(2.5, 2.5), ());
}
{
vector<PointD> const points {
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0}
};
vector<PointD> const points{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
// Also logs a warning message.
TEST_EQUAL(GetPolyLineCenter(points), PointD(0, 0), ());
}
{
vector<PointD> const points {
{0, 0},
{0, 0},
{0, 0},
{0, 0.000001},
{0, 0.000001},
{0, 0.000001},
{0, 0.000001}
};
vector<PointD> const points{{0, 0}, {0, 0}, {0, 0}, {0, 0.000001}, {0, 0.000001}, {0, 0.000001}, {0, 0.000001}};
// Also logs a warning message.
TEST(GetPolyLineCenter(points).EqualDxDy(PointD(0, .0000005), 1e-7), ());
}
@@ -96,28 +72,15 @@ UNIT_TEST(CalculatePolyLineCenter)
UNIT_TEST(CalculateCenter)
{
{
vector<PointD> const points {
{2, 2}
};
TEST_EQUAL(GetBoundingBox(points), RectD({2, 2}, {2, 2}), ());
vector<PointD> const points{{2, 2}};
TEST_EQUAL(GetBoundingBox(points), RectD({2, 2}, {2, 2}), ());
}
{
vector<PointD> const points {
{0, 0},
{1, 1},
{2, 2}
};
vector<PointD> const points{{0, 0}, {1, 1}, {2, 2}};
TEST_EQUAL(GetBoundingBox(points), RectD({0, 0}, {2, 2}), ());
}
{
vector<PointD> const points {
{0, 2},
{1, 1},
{2, 2},
{1, 2},
{2, 2},
{2, 0}
};
vector<PointD> const points{{0, 2}, {1, 1}, {2, 2}, {1, 2}, {2, 2}, {2, 0}};
TEST_EQUAL(GetBoundingBox(points), RectD({0, 0}, {2, 2}), ());
}
}
@@ -125,45 +88,30 @@ UNIT_TEST(CalculateCenter)
UNIT_TEST(CalculatePointOnSurface)
{
{
vector<PointD> const points {
{0, 0},
{1, 1},
{2, 2}
};
vector<PointD> const points{{0, 0}, {1, 1}, {2, 2}};
TEST_EQUAL(GetPointOnSurface(points), PointD(1, 1), ());
}
{
vector<PointD> const points {
{0, 2},
{1, 1},
{2, 2},
{1, 2},
{2, 2},
{2, 0}
};
vector<PointD> const points{{0, 2}, {1, 1}, {2, 2}, {1, 2}, {2, 2}, {2, 0}};
TEST_EQUAL(GetPointOnSurface(points), PointD(1, 1), ());
}
{
vector<PointD> const points {
{0, 0}, {1, 1}, {2, 0},
{1, 1}, {2, 0}, {3, 1}, // Center of this triangle is used as a result.
{2, 0}, {3, 1}, {4, 0},
vector<PointD> const points{
{0, 0}, {1, 1}, {2, 0}, {1, 1}, {2, 0}, {3, 1}, // Center of this triangle is used as a result.
{2, 0}, {3, 1}, {4, 0},
{4, 0}, {3, 1}, {4, 2},
{3, 1}, {4, 2}, {3, 3}, // Or this.
{4, 2}, {3, 3}, {4, 4},
{4, 0}, {3, 1}, {4, 2}, {3, 1}, {4, 2}, {3, 3}, // Or this.
{4, 2}, {3, 3}, {4, 4},
{3, 3}, {4, 4}, {2, 4},
{3, 3}, {2, 4}, {1, 3}, // Or this.
{1, 3}, {2, 4}, {0, 4},
{3, 3}, {4, 4}, {2, 4}, {3, 3}, {2, 4}, {1, 3}, // Or this.
{1, 3}, {2, 4}, {0, 4},
{0, 4}, {1, 3}, {0, 2},
{1, 3}, {0, 2}, {1, 1}, // Or this
{0, 2}, {1, 1}, {0, 0},
{0, 4}, {1, 3}, {0, 2}, {1, 3}, {0, 2}, {1, 1}, // Or this
{0, 2}, {1, 1}, {0, 0},
};
auto const result = GetPointOnSurface(points);
TEST(PointsAlmostEqual(result, {10.0 / 3.0, 2}) || PointsAlmostEqual(result, {2, 2.0 / 3.0}) ||
PointsAlmostEqual(result, {2, 10.0 / 3.0}) || PointsAlmostEqual(result, {2.0 / 3.0, 2}),
PointsAlmostEqual(result, {2, 10.0 / 3.0}) || PointsAlmostEqual(result, {2.0 / 3.0, 2}),
("result = ", result));
}
}