diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 13:58:27 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:12:25 +0200 |
commit | 30f06fac317668c7da977edf13085a0e0e9df964 (patch) | |
tree | 57ca6692d772f98ecbdda2e0d739a69e125f8d52 /test | |
parent | 0978386d9938a7d3f205ec4419bd5213d5f0a579 (diff) |
wa
Diffstat (limited to 'test')
-rw-r--r-- | test/hole.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/test/hole.cpp b/test/hole.cpp index 6cc39af1..2e2acc32 100644 --- a/test/hole.cpp +++ b/test/hole.cpp @@ -6,40 +6,38 @@ namespace { using bbox = cut_rectangle_result::bbox; -template<Int x, Int y> -void test1() +void test1(Vector2i offset) { - static constexpr auto vec = Vector2i{x, y}; - static constexpr auto rect = bbox{{}, {50, 50}}; + 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 }; + constexpr auto cutʹ = [](bbox rect, bbox hole, Vector2i offset) { + auto rectʹ = bbox { rect.position + offset, rect.bbox_size }; + auto holeʹ = bbox { hole.position + offset, hole.bbox_size }; return cut_rectangle(rectʹ, holeʹ).size; }; #if 1 - fm_assert_not_equal(0, cutʹ(rect, {{ 49, 0}, {50, 50}})); - fm_assert_not_equal(0, cutʹ(rect, {{ 0, 49}, {50, 50}})); - fm_assert_not_equal(0, cutʹ(rect, {{ 49, 49}, {50, 50}})); + fm_assert_not_equal(0, cutʹ(rect, {{ 49, 0}, {50, 50}}, offset)); + fm_assert_not_equal(0, cutʹ(rect, {{ 0, 49}, {50, 50}}, offset)); + fm_assert_not_equal(0, cutʹ(rect, {{ 49, 49}, {50, 50}}, offset)); #endif #if 1 - fm_assert_not_equal(0, cutʹ(rect, {{-49, 0}, {50, 50}})); - fm_assert_not_equal(0, cutʹ(rect, {{ 0, -49}, {50, 50}})); - fm_assert_not_equal(0, cutʹ(rect, {{ 49, -49}, {50, 50}})); + fm_assert_not_equal(0, cutʹ(rect, {{-49, 0}, {50, 50}}, offset)); + fm_assert_not_equal(0, cutʹ(rect, {{ 0, -49}, {50, 50}}, offset)); + fm_assert_not_equal(0, cutʹ(rect, {{ 49, -49}, {50, 50}}, offset)); #endif #if 1 - fm_assert_equal(0, cutʹ(rect, {{50, 0}, {50, 50}})); - fm_assert_equal(0, cutʹ(rect, {{ 0, 50}, {50, 50}})); - fm_assert_equal(0, cutʹ(rect, {{50, 50}, {50, 50}})); + fm_assert_equal(0, cutʹ(rect, {{50, 0}, {50, 50}}, offset)); + fm_assert_equal(0, cutʹ(rect, {{ 0, 50}, {50, 50}}, offset)); + fm_assert_equal(0, cutʹ(rect, {{50, 50}, {50, 50}}, offset)); #endif #if 1 - fm_assert_equal(1, cutʹ(rect, {{ 9, 9}, {70, 70}})); - fm_assert_equal(1, cutʹ(rect, {{10, 10}, {70, 70}})); + fm_assert_equal(1, cutʹ(rect, {{ 9, 9}, {70, 70}}, offset)); + fm_assert_equal(1, cutʹ(rect, {{10, 10}, {70, 70}}, offset)); #endif #if 1 - 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}})); + fm_assert_equal(1, cutʹ(rect, {{1, 0}, {50, 50}}, offset)); + fm_assert_equal(1, cutʹ(rect, {{0, 1}, {50, 50}}, offset)); + fm_assert_equal(2, cutʹ(rect, {{1, 1}, {50, 50}}, offset)); #endif #if 1 // todo! coverage @@ -50,11 +48,16 @@ void test1() void Test::test_hole() { - test1< 0, 0 >(); - test1< 110, 105 >(); - test1< 15, 110 >(); - test1< - 15, -110 >(); - test1< -110, -15 >(); + constexpr Vector2i offsets[] = { + { 0, 0}, + { 110, 105}, + { 15, 110}, + {- 15, -110}, + {-110, -15}, + }; + + for (auto offset : offsets) + test1(offset); } } // namespace floormat |