From 0978386d9938a7d3f205ec4419bd5213d5f0a579 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 26 May 2024 10:19:37 +0200 Subject: w a --- test/hole.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/hole.cpp b/test/hole.cpp index 4ad3c21a..6cc39af1 100644 --- a/test/hole.cpp +++ b/test/hole.cpp @@ -1,7 +1,7 @@ #include "app.hpp" #include "src/hole.hpp" -namespace floormat::Hole { +namespace floormat { namespace { using bbox = cut_rectangle_result::bbox; @@ -10,7 +10,8 @@ template void test1() { static constexpr auto vec = Vector2i{x, y}; - constexpr auto rect = bbox{{}, {50, 50}}; + static constexpr auto rect = bbox{{}, {50, 50}}; + constexpr auto cutʹ = [](bbox rect, bbox hole) { auto rectʹ = bbox { rect.position + vec, rect.bbox_size }; auto holeʹ = bbox { hole.position + vec, hole.bbox_size }; @@ -32,13 +33,13 @@ void test1() fm_assert_equal(0, cutʹ(rect, {{50, 50}, {50, 50}})); #endif #if 1 - fm_assert_equal(9, cutʹ(rect, {{ 9, 9}, {70, 70}})); - fm_assert_equal(9, cutʹ(rect, {{10, 10}, {70, 70}})); + fm_assert_equal(1, cutʹ(rect, {{ 9, 9}, {70, 70}})); + fm_assert_equal(1, cutʹ(rect, {{10, 10}, {70, 70}})); #endif #if 1 - fm_assert_equal(12, cutʹ(rect, {{1, 0}, {50, 50}})); - fm_assert_equal(12, cutʹ(rect, {{0, 1}, {50, 50}})); - fm_assert_equal(11, cutʹ(rect, {{1, 1}, {50, 50}})); + fm_assert_equal(1, cutʹ(rect, {{1, 0}, {50, 50}})); + fm_assert_equal(1, cutʹ(rect, {{0, 1}, {50, 50}})); + fm_assert_equal(2, cutʹ(rect, {{1, 1}, {50, 50}})); #endif #if 1 // todo! coverage @@ -46,16 +47,14 @@ void test1() } } // namespace -} // namespace floormat::Hole -namespace floormat { void Test::test_hole() { - Hole::test1< 0, 0 >(); - Hole::test1< 110, 105 >(); - Hole::test1< 15, 110 >(); - Hole::test1< - 15, -110 >(); - Hole::test1< -110, -15 >(); + test1< 0, 0 >(); + test1< 110, 105 >(); + test1< 15, 110 >(); + test1< - 15, -110 >(); + test1< -110, -15 >(); } } // namespace floormat -- cgit v1.2.3