2022-07-25 00:36:05 -06:00
|
|
|
#include <SFML/Graphics/Drawable.hpp>
|
2023-01-21 13:21:49 -08:00
|
|
|
#include <SFML/Graphics/RenderTexture.hpp>
|
2022-07-25 00:36:05 -06:00
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2023-01-21 13:21:49 -08:00
|
|
|
|
|
|
|
#include <GraphicsUtil.hpp>
|
2024-02-08 14:28:57 +01:00
|
|
|
#include <WindowUtil.hpp>
|
2022-07-25 00:36:05 -06:00
|
|
|
#include <type_traits>
|
|
|
|
|
2023-01-21 13:21:49 -08:00
|
|
|
class DrawableTest : public sf::Drawable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int callCount() const
|
|
|
|
{
|
|
|
|
return m_callCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2024-04-16 10:41:43 -06:00
|
|
|
void draw(sf::RenderTarget&, sf::RenderStates) const override
|
2023-01-21 13:21:49 -08:00
|
|
|
{
|
|
|
|
++m_callCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutable int m_callCount{};
|
|
|
|
};
|
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
TEST_CASE("[Graphics] sf::Drawable", runDisplayTests())
|
2023-01-21 13:21:49 -08:00
|
|
|
{
|
2023-01-17 21:51:08 -07: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-21 13:21:49 -08:00
|
|
|
{
|
|
|
|
const DrawableTest drawableTest;
|
|
|
|
CHECK(drawableTest.callCount() == 0);
|
|
|
|
}
|
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
SECTION("draw()")
|
2023-01-21 13:21:49 -08:00
|
|
|
{
|
|
|
|
const DrawableTest drawableTest;
|
2024-07-06 04:24:00 +02:00
|
|
|
sf::RenderTexture renderTexture({32, 32});
|
2023-01-21 13:21:49 -08:00
|
|
|
CHECK(drawableTest.callCount() == 0);
|
|
|
|
renderTexture.draw(drawableTest);
|
|
|
|
CHECK(drawableTest.callCount() == 1);
|
|
|
|
}
|
|
|
|
}
|