mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 14:21:04 +08:00
Add tests for sf::Image::loadFromFile
This commit is contained in:
parent
3d63de9a21
commit
c9d9f84a0e
@ -86,6 +86,49 @@ TEST_CASE("[Graphics] sf::Image")
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("loadFromFile()")
|
||||
{
|
||||
sf::Image image;
|
||||
|
||||
SECTION("bmp")
|
||||
{
|
||||
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.bmp"));
|
||||
CHECK(image.getPixel({0, 0}) == sf::Color::White);
|
||||
CHECK(image.getPixel({200, 150}) == sf::Color(144, 208, 62));
|
||||
}
|
||||
|
||||
SECTION("png")
|
||||
{
|
||||
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.png"));
|
||||
CHECK(image.getPixel({0, 0}) == sf::Color(255, 255, 255, 0));
|
||||
CHECK(image.getPixel({200, 150}) == sf::Color(144, 208, 62));
|
||||
}
|
||||
|
||||
SECTION("jpg")
|
||||
{
|
||||
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.jpg"));
|
||||
CHECK(image.getPixel({0, 0}) == sf::Color::White);
|
||||
CHECK(image.getPixel({200, 150}) == sf::Color(144, 208, 62));
|
||||
}
|
||||
|
||||
SECTION("gif")
|
||||
{
|
||||
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.gif"));
|
||||
CHECK(image.getPixel({0, 0}) == sf::Color::White);
|
||||
CHECK(image.getPixel({200, 150}) == sf::Color(146, 210, 62));
|
||||
}
|
||||
|
||||
SECTION("psd")
|
||||
{
|
||||
REQUIRE(image.loadFromFile("Graphics/sfml-logo-big.psd"));
|
||||
CHECK(image.getPixel({0, 0}) == sf::Color::White);
|
||||
CHECK(image.getPixel({200, 150}) == sf::Color(144, 208, 62));
|
||||
}
|
||||
|
||||
CHECK(image.getSize() == sf::Vector2u(1001, 304));
|
||||
CHECK(image.getPixelsPtr() != nullptr);
|
||||
}
|
||||
|
||||
SECTION("Set/get pixel")
|
||||
{
|
||||
sf::Image image;
|
||||
|
BIN
test/Graphics/sfml-logo-big.bmp
Normal file
BIN
test/Graphics/sfml-logo-big.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 892 KiB |
BIN
test/Graphics/sfml-logo-big.gif
Normal file
BIN
test/Graphics/sfml-logo-big.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
test/Graphics/sfml-logo-big.jpg
Normal file
BIN
test/Graphics/sfml-logo-big.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
test/Graphics/sfml-logo-big.png
Normal file
BIN
test/Graphics/sfml-logo-big.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
test/Graphics/sfml-logo-big.psd
Normal file
BIN
test/Graphics/sfml-logo-big.psd
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user