mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 21:53:37 +02:00
Add tests for sfTexture
This commit is contained in:
7 files changed
+67
-1
No files matched your search
+2
-1
@@ -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
|
||||
|
||||
@@ -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.
Reference in new issue
Block a user