Fixed move semantics for sf::Cursor and added test for it

This commit is contained in:
alireza 2023-04-22 19:29:05 +03:00 committed by GitHub
parent 692fe84331
commit 5480bf8a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -145,13 +145,13 @@ public:
/// \brief Move constructor
///
////////////////////////////////////////////////////////////
Cursor(Cursor&&) noexcept = default;
Cursor(Cursor&&) noexcept;
////////////////////////////////////////////////////////////
/// \brief Move assignment
///
////////////////////////////////////////////////////////////
Cursor& operator=(Cursor&&) noexcept = default;
Cursor& operator=(Cursor&&) noexcept;
////////////////////////////////////////////////////////////
/// \brief Create a cursor with the provided image

View File

@ -44,6 +44,14 @@ Cursor::Cursor() : m_impl(std::make_unique<priv::CursorImpl>())
Cursor::~Cursor() = default;
////////////////////////////////////////////////////////////
Cursor::Cursor(Cursor&&) noexcept = default;
////////////////////////////////////////////////////////////
Cursor& Cursor::operator=(Cursor&&) noexcept = default;
////////////////////////////////////////////////////////////
bool Cursor::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot)
{

View File

@ -19,6 +19,22 @@ TEST_CASE("[Window] sf::Cursor" * doctest::skip(true))
const sf::Cursor cursor;
}
SUBCASE("Move semantics")
{
SUBCASE("Construction")
{
sf::Cursor movedCursor;
const sf::Cursor cursor(std::move(movedCursor));
}
SUBCASE("Assignment")
{
sf::Cursor movedCursor;
sf::Cursor cursor;
cursor = std::move(movedCursor);
}
}
SUBCASE("loadFromPixels()")
{
sf::Cursor cursor;