From 976bbda91106c6070951970e833f42e98edc8279 Mon Sep 17 00:00:00 2001 From: Jim-Marsden Date: Sat, 21 Jan 2023 13:21:49 -0800 Subject: [PATCH] Drawable Test --- test/Graphics/Drawable.test.cpp | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/Graphics/Drawable.test.cpp b/test/Graphics/Drawable.test.cpp index 961acc8c3..e5c462249 100644 --- a/test/Graphics/Drawable.test.cpp +++ b/test/Graphics/Drawable.test.cpp @@ -1,5 +1,9 @@ #include +#include +#include + +#include #include static_assert(!std::is_constructible_v); @@ -7,3 +11,41 @@ static_assert(!std::is_copy_constructible_v); static_assert(std::is_copy_assignable_v); static_assert(!std::is_nothrow_move_constructible_v); static_assert(std::is_nothrow_move_assignable_v); +static_assert(std::is_abstract_v); +static_assert(std::has_virtual_destructor_v); + +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); + } +}