Add tests for sf::RenderTexture
The generateMipmap test was failing because I forgot to enable MESA in the MinGW Static Standard Library job.
This commit is contained in:
parent
0a3b0d1d16
commit
d7ab9208be
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -60,7 +60,7 @@ jobs:
|
|||||||
config: { name: OpenGL ES, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DSFML_OPENGL_ES=ON }
|
config: { name: OpenGL ES, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DSFML_OPENGL_ES=ON }
|
||||||
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
||||||
- platform: { name: Windows MinGW, os: windows-2022 }
|
- platform: { name: Windows MinGW, os: windows-2022 }
|
||||||
config: { name: Static Standard Libraries, flags: -GNinja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DSFML_USE_STATIC_STD_LIBS=TRUE }
|
config: { name: Static Standard Libraries, flags: -GNinja -DSFML_USE_MESA3D=TRUE -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DSFML_USE_STATIC_STD_LIBS=TRUE }
|
||||||
- platform: { name: macOS, os: macos-12 }
|
- platform: { name: macOS, os: macos-12 }
|
||||||
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
||||||
- platform: { name: Android, os: ubuntu-22.04 }
|
- platform: { name: Android, os: ubuntu-22.04 }
|
||||||
|
@ -170,6 +170,7 @@ Vector2u RenderTexture::getSize() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderTexture::isSrgb() const
|
bool RenderTexture::isSrgb() const
|
||||||
{
|
{
|
||||||
|
assert(m_impl && "Must call RenderTexture::create first");
|
||||||
return m_impl->isSrgb();
|
return m_impl->isSrgb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,79 @@
|
|||||||
#include <SFML/Graphics/RenderTexture.hpp>
|
#include <SFML/Graphics/RenderTexture.hpp>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include <WindowUtil.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
static_assert(!std::is_copy_constructible_v<sf::RenderTexture>);
|
TEST_CASE("[Graphics] sf::RenderTexture", runDisplayTests())
|
||||||
static_assert(!std::is_copy_assignable_v<sf::RenderTexture>);
|
{
|
||||||
static_assert(!std::is_nothrow_move_constructible_v<sf::RenderTexture>);
|
SECTION("Type traits")
|
||||||
static_assert(!std::is_nothrow_move_assignable_v<sf::RenderTexture>);
|
{
|
||||||
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::RenderTexture>);
|
||||||
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::RenderTexture>);
|
||||||
|
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::RenderTexture>);
|
||||||
|
STATIC_CHECK(!std::is_nothrow_move_assignable_v<sf::RenderTexture>);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Construction")
|
||||||
|
{
|
||||||
|
const sf::RenderTexture renderTexture;
|
||||||
|
CHECK(!renderTexture.isSmooth());
|
||||||
|
CHECK(!renderTexture.isRepeated());
|
||||||
|
CHECK(renderTexture.getSize() == sf::Vector2u(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("create()")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
CHECK(!renderTexture.create({1'000'000, 1'000'000}));
|
||||||
|
CHECK(renderTexture.create({480, 360}));
|
||||||
|
CHECK(!renderTexture.isSmooth());
|
||||||
|
CHECK(!renderTexture.isRepeated());
|
||||||
|
CHECK(renderTexture.getSize() == sf::Vector2u(480, 360));
|
||||||
|
CHECK(!renderTexture.isSrgb());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("getMaximumAntialiasingLevel()")
|
||||||
|
{
|
||||||
|
CHECK(sf::RenderTexture::getMaximumAntialiasingLevel() < 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Set/get smooth")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
renderTexture.setSmooth(true);
|
||||||
|
CHECK(renderTexture.isSmooth());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Set/get repeated")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
renderTexture.setRepeated(true);
|
||||||
|
CHECK(renderTexture.isRepeated());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("generateMipmap()")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
CHECK(!renderTexture.generateMipmap());
|
||||||
|
CHECK(renderTexture.create({480, 360}));
|
||||||
|
CHECK(renderTexture.generateMipmap());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("setActive()")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
CHECK(!renderTexture.setActive());
|
||||||
|
CHECK(renderTexture.create({480, 360}));
|
||||||
|
CHECK(renderTexture.setActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("getTexture()")
|
||||||
|
{
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
CHECK(renderTexture.getTexture().getSize() == sf::Vector2u(0, 0));
|
||||||
|
CHECK(renderTexture.create({480, 360}));
|
||||||
|
CHECK(renderTexture.getTexture().getSize() == sf::Vector2u(480, 360));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user