Add tests for sf::Image::loadFromFile failure

This commit is contained in:
Chris Thrasher 2023-10-26 17:37:11 -06:00
parent fd2c42c7d1
commit 0fcd1dd0f1

View File

@ -90,6 +90,17 @@ TEST_CASE("[Graphics] sf::Image")
{ {
sf::Image image; sf::Image image;
SECTION("Invalid file")
{
CHECK(!image.loadFromFile("."));
CHECK(!image.loadFromFile("this/does/not/exist.jpg"));
CHECK(image.getSize() == sf::Vector2u(0, 0));
CHECK(image.getPixelsPtr() == nullptr);
}
SECTION("Successful load")
{
SECTION("bmp") SECTION("bmp")
{ {
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.bmp")); REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.bmp"));
@ -128,6 +139,7 @@ TEST_CASE("[Graphics] sf::Image")
CHECK(image.getSize() == sf::Vector2u(1001, 304)); CHECK(image.getSize() == sf::Vector2u(1001, 304));
CHECK(image.getPixelsPtr() != nullptr); CHECK(image.getPixelsPtr() != nullptr);
} }
}
SECTION("saveToFile()") SECTION("saveToFile()")
{ {