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

@@ -10,7 +10,7 @@ using namespace m2;
double const kEps = 1e-10;
void TestIntersectionResult(IntersectionResult const & result, IntersectionResult::Type expectedType,
PointD const & expectedPoint)
PointD const & expectedPoint)
{
TEST_EQUAL(result.m_type, expectedType, ());
TEST(AlmostEqualAbs(result.m_point, expectedPoint, kEps), (result.m_point, expectedPoint, kEps));
@@ -55,54 +55,45 @@ UNIT_TEST(SegmentIntersection_Intersect)
UNIT_TEST(SegmentIntersection_NoIntersectionPoint)
{
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {1.0, 0.0}), Segment2D({2.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {1.0, 0.0}), Segment2D({2.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {1.0, 1.0}), Segment2D({2.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {1.0, 1.0}), Segment2D({2.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {1.0, 1.0}), Segment2D({4.0, 4.0}, {2.0, 2.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {1.0, 1.0}), Segment2D({4.0, 4.0}, {2.0, 2.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {4.0, 4.0}), Segment2D({10.0, 0.0}, {6.0, 4.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {4.0, 4.0}), Segment2D({10.0, 0.0}, {6.0, 4.0}), kEps).m_type,
IntersectionResult::Type::Zero, ());
}
UNIT_TEST(SegmentIntersection_OneIntersectionPoint)
{
// Two intersected segments. The intersection point is in the middle of both of them.
{
auto const result =
Intersect(Segment2D({-1.0, -1.0}, {1.0, 1.0}), Segment2D({-1.0, 0.0}, {1.0, 0.0}), kEps);
auto const result = Intersect(Segment2D({-1.0, -1.0}, {1.0, 1.0}), Segment2D({-1.0, 0.0}, {1.0, 0.0}), kEps);
TestIntersectionResult(result, IntersectionResult::Type::One, {0.0, 0.0});
}
{
auto const result =
Intersect(Segment2D({0.0, 0.0}, {10.0, 10.0}), Segment2D({10.0, 0.0}, {0.0, 10.0}), kEps);
auto const result = Intersect(Segment2D({0.0, 0.0}, {10.0, 10.0}), Segment2D({10.0, 0.0}, {0.0, 10.0}), kEps);
TestIntersectionResult(result, IntersectionResult::Type::One, {5.0, 5.0});
}
// Two intersected segments. The intersection point is in an end of both of them.
{
auto const result =
Intersect(Segment2D({-1.0, -1.0}, {0.0, 0.0}), Segment2D({0.0, 0.0}, {11.0, 0.0}), kEps);
auto const result = Intersect(Segment2D({-1.0, -1.0}, {0.0, 0.0}), Segment2D({0.0, 0.0}, {11.0, 0.0}), kEps);
TestIntersectionResult(result, IntersectionResult::Type::One, {0.0, 0.0});
}
}
UNIT_TEST(SegmentIntersection_InfinityIntersectionPoints)
{
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {2.0, 0.0}), Segment2D({1.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Infinity, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {2.0, 0.0}), Segment2D({1.0, 0.0}, {4.0, 0.0}), kEps).m_type,
IntersectionResult::Type::Infinity, ());
TEST_EQUAL(
Intersect(Segment2D({0.0, 0.0}, {2.0, 4.0}), Segment2D({1.0, 2.0}, {2.0, 4.0}), kEps).m_type,
IntersectionResult::Type::Infinity, ());
TEST_EQUAL(Intersect(Segment2D({0.0, 0.0}, {2.0, 4.0}), Segment2D({1.0, 2.0}, {2.0, 4.0}), kEps).m_type,
IntersectionResult::Type::Infinity, ());
}
} // namespace segment2d_tests