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

+2 -1
View File
@@ -53,13 +53,14 @@ add_executable(test-csfml-graphics
Graphics/RenderStates.test.cpp
Graphics/Shape.test.cpp
Graphics/StencilMode.test.cpp
Graphics/Texture.test.cpp
Graphics/Transform.test.cpp
Graphics/VertexArray.test.cpp
Graphics/View.test.cpp
)
target_link_libraries(test-csfml-graphics PRIVATE csfml-graphics Catch2::Catch2WithMain SFML::Graphics)
set_target_warnings(test-csfml-graphics)
catch_discover_tests(test-csfml-graphics)
catch_discover_tests(test-csfml-graphics WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test-csfml-network
Network/Ftp.test.cpp
+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.