diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 928d1d5..30c011c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 diff --git a/test/Graphics/Texture.test.cpp b/test/Graphics/Texture.test.cpp new file mode 100644 index 0000000..8462de1 --- /dev/null +++ b/test/Graphics/Texture.test.cpp @@ -0,0 +1,65 @@ +#include + +#include +#include + +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); + } +} diff --git a/test/Graphics/sfml-logo-big.bmp b/test/Graphics/sfml-logo-big.bmp new file mode 100644 index 0000000..615a25e Binary files /dev/null and b/test/Graphics/sfml-logo-big.bmp differ diff --git a/test/Graphics/sfml-logo-big.gif b/test/Graphics/sfml-logo-big.gif new file mode 100644 index 0000000..40d594d Binary files /dev/null and b/test/Graphics/sfml-logo-big.gif differ diff --git a/test/Graphics/sfml-logo-big.jpg b/test/Graphics/sfml-logo-big.jpg new file mode 100644 index 0000000..7b7c5d4 Binary files /dev/null and b/test/Graphics/sfml-logo-big.jpg differ diff --git a/test/Graphics/sfml-logo-big.png b/test/Graphics/sfml-logo-big.png new file mode 100644 index 0000000..d22d46d Binary files /dev/null and b/test/Graphics/sfml-logo-big.png differ diff --git a/test/Graphics/sfml-logo-big.psd b/test/Graphics/sfml-logo-big.psd new file mode 100644 index 0000000..8c107d6 Binary files /dev/null and b/test/Graphics/sfml-logo-big.psd differ