From 6782b821b97ff713a488b69ca5d2ff3764f2cf9f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 27 Oct 2020 12:20:41 +1000 Subject: [PATCH] region: add some region-region intersects tests --- test/region.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/region.cpp b/test/region.cpp index 6a56498a..74313c07 100644 --- a/test/region.cpp +++ b/test/region.cpp @@ -24,6 +24,30 @@ main (int, char **) tap.expect (!a.intersects (b), "simple 2d intersection"); } + { + using p_t = cruft::point2i; + using e_t = cruft::extent2i; + + struct { + cruft::region2i a; + cruft::region2i b; + bool intersection; + char const *message; + } const TESTS[] = { + { + .a = { p_t { 58, 22 }, e_t { 13, 8 } }, + .b = { p_t { 58, 22 }, e_t { 7, 7 } }, + .intersection = true, + .message = "Coaligned base", + }, + }; + + for (auto const &[a, b, res, msg]: TESTS) { + tap.expect_eq (a.intersects (b), res, "intersection a-on-b: %!", msg); + tap.expect_eq (b.intersects (a), res, "intersection b-on-a: %!", msg); + } + } + // check various floating point maximums successfully test for // intersection. the concern is that infinities are incorrectly handled // in some comparisons.