region: add a single 'covers' test

This commit is contained in:
Danny Robson 2020-10-27 16:00:53 +10:00
parent 0d9a80ea84
commit 58d86bbc95

View File

@ -111,6 +111,29 @@ main (int, char **)
);
};
// Check that 'covers' behaves as expected. ie, a covers b.
{
using p = cruft::point2i;
using e = cruft::extent2i;
struct {
cruft::region2i a;
cruft::region2i b;
bool expected;
char const *message;
} TESTS[] = {
{
.a = { p { 0, 0, }, e { 32, 32, } },
.b = { p { 27, 4, }, e { 8, 13, } },
.expected = false,
.message = "a exceeds +x margin",
}
};
for (auto const &[a, b, expected, msg]: TESTS)
tap.expect_eq (a.covers (b), expected, "covers: %!", msg);
}
// ensure make_region covers the expected values
{
const cruft::region2i REGION {