Add tests for sfTexture

This commit is contained in:
Chris Thrasher committed 2025-06-08 21:27:12 -06:00
1 parent e39a0b1ab8
commit cf80a809f3
7 files changed
+67 -1

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
#include <CSFML/Graphics/Texture.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
TEST_CASE("[Graphics] sfTexture")
{
SECTION("sfTexture_create")
{
const sfTexture* texture = sfTexture_create({100, 100});
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x == 100);
CHECK(sfTexture_getSize(texture).y == 100);
CHECK(!sfTexture_isSmooth(texture));
CHECK(!sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createSrgb")
{
const sfTexture* texture = sfTexture_createSrgb({100, 100});
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x == 100);
CHECK(sfTexture_getSize(texture).y == 100);
CHECK(!sfTexture_isSmooth(texture));
CHECK(sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createFromFile")
{
const char* fileExtension = GENERATE("bmp", "gif", "jpg", "png", "psd");
const auto filename = std::string("Graphics/sfml-logo-big.") + fileExtension;
INFO("Filename: " << filename);
const sfTexture* texture = sfTexture_createFromFile(filename.c_str(), nullptr);
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x > 0);
CHECK(sfTexture_getSize(texture).y > 0);
CHECK(!sfTexture_isSmooth(texture));
CHECK(!sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createSrgbFromFile")
{
const char* fileExtension = GENERATE("bmp", "gif", "jpg", "png", "psd");
const auto filename = std::string("Graphics/sfml-logo-big.") + fileExtension;
INFO("Filename: " << filename);
const sfTexture* texture = sfTexture_createSrgbFromFile(filename.c_str(), nullptr);
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x > 0);
CHECK(sfTexture_getSize(texture).y > 0);
CHECK(!sfTexture_isSmooth(texture));
CHECK(sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 892 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.