Added tests to check for exceptions being thrown on channel-out-of-range for FillChannel

This commit is contained in:
Leonetienne 2022-03-06 14:19:22 +01:00
parent dd2f0d0496
commit 61c2808e2b
2 changed files with 36 additions and 2 deletions

View File

@ -104,5 +104,38 @@ TEST_CASE(__FILE__"/WillWriteTheCorrectData", "[FillChannel]")
// Assert that they are equal
REQUIRE(bmp == reference);
}
return;
}
// Tests that a runtime error is thrown if the channel index is out of range
TEST_CASE(__FILE__"/RuntimeError_on_channel_out_of_range", "[FillChannel]")
{
SECTION("RGB_OUT_OF_RANGE") {
BMP bmp(Vector2i(800, 600), Colormode::RGB);
REQUIRE_THROWS_AS(
bmp.FillChannel(3, 0xFF)
, std::runtime_error
);
}
SECTION("RGBA_OK") {
BMP bmp(Vector2i(800, 600), Colormode::RGBA);
bmp.FillChannel(3, 0xFF);
}
SECTION("RGBA_OUT_OF_RANGE") {
BMP bmp(Vector2i(800, 600), Colormode::RGBA);
REQUIRE_THROWS_AS(
bmp.FillChannel(4, 0xFF)
, std::runtime_error
);
}
return;
}

View File

@ -75,9 +75,10 @@ TEST_CASE(__FILE__"/RuntimeError_on_channel_out_of_range", "[SwapChannels]")
BMP bmp(Vector2i(800, 600), Colormode::RGBA);
REQUIRE_THROWS_AS(
bmp.SwapChannels(0, 4)
, std::runtime_error
bmp.SwapChannels(0, 4)
, std::runtime_error
);
}
return;
}