mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Drawable Test
This commit is contained in:
parent
4c8b770992
commit
976bbda911
@ -1,5 +1,9 @@
|
|||||||
#include <SFML/Graphics/Drawable.hpp>
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
|
#include <SFML/Graphics/RenderTexture.hpp>
|
||||||
|
|
||||||
|
#include <doctest/doctest.h>
|
||||||
|
|
||||||
|
#include <GraphicsUtil.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
static_assert(!std::is_constructible_v<sf::Drawable>);
|
static_assert(!std::is_constructible_v<sf::Drawable>);
|
||||||
@ -7,3 +11,41 @@ static_assert(!std::is_copy_constructible_v<sf::Drawable>);
|
|||||||
static_assert(std::is_copy_assignable_v<sf::Drawable>);
|
static_assert(std::is_copy_assignable_v<sf::Drawable>);
|
||||||
static_assert(!std::is_nothrow_move_constructible_v<sf::Drawable>);
|
static_assert(!std::is_nothrow_move_constructible_v<sf::Drawable>);
|
||||||
static_assert(std::is_nothrow_move_assignable_v<sf::Drawable>);
|
static_assert(std::is_nothrow_move_assignable_v<sf::Drawable>);
|
||||||
|
static_assert(std::is_abstract_v<sf::Drawable>);
|
||||||
|
static_assert(std::has_virtual_destructor_v<sf::Drawable>);
|
||||||
|
|
||||||
|
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{};
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("[Graphics] sf::Drawable" * doctest::skip(skipDisplayTests))
|
||||||
|
{
|
||||||
|
SUBCASE("Construction")
|
||||||
|
{
|
||||||
|
const DrawableTest drawableTest;
|
||||||
|
CHECK(drawableTest.callCount() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("draw()")
|
||||||
|
{
|
||||||
|
const DrawableTest drawableTest;
|
||||||
|
sf::RenderTexture renderTexture;
|
||||||
|
CHECK(renderTexture.create({32, 32}));
|
||||||
|
CHECK(drawableTest.callCount() == 0);
|
||||||
|
renderTexture.draw(drawableTest);
|
||||||
|
CHECK(drawableTest.callCount() == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user