SFML/test/Graphics/Drawable.test.cpp

55 lines
1.4 KiB
C++
Raw Permalink Normal View History

#include <SFML/Graphics/Drawable.hpp>
2023-01-22 05:21:49 +08:00
#include <SFML/Graphics/RenderTexture.hpp>
2023-01-18 12:51:08 +08:00
#include <catch2/catch_test_macros.hpp>
2023-01-22 05:21:49 +08:00
#include <GraphicsUtil.hpp>
#include <type_traits>
2023-01-22 05:21:49 +08:00
class DrawableTest : public sf::Drawable
{
public:
int callCount() const
{
return m_callCount;
}
private:
void draw(sf::RenderTarget&, const sf::RenderStates&) const override
{
++m_callCount;
}
mutable int m_callCount{};
};
2023-01-18 12:51:08 +08:00
TEST_CASE("[Graphics] sf::Drawable", runDisplayTests())
2023-01-22 05:21:49 +08:00
{
2023-01-18 12:51:08 +08:00
SECTION("Type traits")
{
STATIC_CHECK(!std::is_constructible_v<sf::Drawable>);
STATIC_CHECK(!std::is_copy_constructible_v<sf::Drawable>);
STATIC_CHECK(std::is_copy_assignable_v<sf::Drawable>);
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::Drawable>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Drawable>);
STATIC_CHECK(std::is_abstract_v<sf::Drawable>);
STATIC_CHECK(std::has_virtual_destructor_v<sf::Drawable>);
}
SECTION("Construction")
2023-01-22 05:21:49 +08:00
{
const DrawableTest drawableTest;
CHECK(drawableTest.callCount() == 0);
}
2023-01-18 12:51:08 +08:00
SECTION("draw()")
2023-01-22 05:21:49 +08:00
{
const DrawableTest drawableTest;
sf::RenderTexture renderTexture;
CHECK(renderTexture.create({32, 32}));
CHECK(drawableTest.callCount() == 0);
renderTexture.draw(drawableTest);
CHECK(drawableTest.callCount() == 1);
}
}