chore(region): add additional tests

This commit is contained in:
fallenoak 2023-03-31 22:29:49 -05:00
parent b05b987e73
commit f10552acea
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D

View file

@ -13,7 +13,7 @@ TEST_CASE("SRgnCreate", "[region]") {
} }
TEST_CASE("SRgnCombineRectf", "[region]") { TEST_CASE("SRgnCombineRectf", "[region]") {
SECTION("combines the region with the given rect using combine mode 2") { SECTION("combines the region with a single given rect 1") {
HSRGN region; HSRGN region;
SRgnCreate(&region, 0); SRgnCreate(&region, 0);
@ -31,7 +31,7 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
SRgnDelete(region); SRgnDelete(region);
} }
SECTION("combines the region with the given rects using combine modes 2 and 4") { SECTION("combines the region with multiple given rects 1") {
HSRGN region; HSRGN region;
SRgnCreate(&region, 0); SRgnCreate(&region, 0);
@ -51,4 +51,46 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
SRgnDelete(region); SRgnDelete(region);
} }
SECTION("combines the region with multiple given rects 2") {
HSRGN region;
SRgnCreate(&region, 0);
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
SRgnCombineRectf(region, &baseRect, nullptr, 2);
RECTF newRect = { 0.0f, 0.0f, 1.0f, 1.0f };
SRgnCombineRectf(region, &newRect, nullptr, 4);
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
SRgnGetBoundingRectf(region, &boundingRect);
REQUIRE(boundingRect.left == 0.0f);
REQUIRE(boundingRect.bottom == 0.0f);
REQUIRE(boundingRect.right == 0.0f);
REQUIRE(boundingRect.top == 0.0f);
SRgnDelete(region);
}
SECTION("combines the region with multiple given rects 3") {
HSRGN region;
SRgnCreate(&region, 0);
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
SRgnCombineRectf(region, &baseRect, nullptr, 2);
RECTF newRect = { 0.0f, 1.0f, 1.0f, 1.0f };
SRgnCombineRectf(region, &newRect, nullptr, 4);
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
SRgnGetBoundingRectf(region, &boundingRect);
REQUIRE(boundingRect.left == 0.0f);
REQUIRE(boundingRect.bottom == 0.0f);
REQUIRE(boundingRect.right == 1.0f);
REQUIRE(boundingRect.top == 1.0f);
SRgnDelete(region);
}
} }