SFML/test/Window/Cursor.test.cpp

71 lines
2.3 KiB
C++
Raw Normal View History

#include <SFML/Window/Cursor.hpp>
2023-01-18 12:51:08 +08:00
#include <catch2/catch_test_macros.hpp>
2023-02-12 09:58:49 +08:00
#include <WindowUtil.hpp>
#include <array>
#include <type_traits>
2023-01-18 12:51:08 +08:00
// Skip these tests with [.display] because they fail when using DRM which hasn't implemented sf::Cursor
TEST_CASE("[Window] sf::Cursor", "[.display]")
2023-02-12 09:58:49 +08:00
{
2023-01-18 12:51:08 +08:00
SECTION("Type traits")
{
STATIC_CHECK(!std::is_copy_constructible_v<sf::Cursor>);
STATIC_CHECK(!std::is_copy_assignable_v<sf::Cursor>);
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::Cursor>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Cursor>);
}
SECTION("Construction")
2023-02-12 09:58:49 +08:00
{
const sf::Cursor cursor;
}
2023-01-18 12:51:08 +08:00
SECTION("Move semantics")
{
2023-01-18 12:51:08 +08:00
SECTION("Construction")
{
sf::Cursor movedCursor;
const sf::Cursor cursor(std::move(movedCursor));
}
2023-01-18 12:51:08 +08:00
SECTION("Assignment")
{
sf::Cursor movedCursor;
sf::Cursor cursor;
cursor = std::move(movedCursor);
}
}
2023-01-18 12:51:08 +08:00
SECTION("loadFromPixels()")
2023-02-12 09:58:49 +08:00
{
sf::Cursor cursor;
std::array<std::uint8_t, 4> pixels{};
CHECK(!cursor.loadFromPixels(nullptr, {}, {}));
CHECK(!cursor.loadFromPixels(pixels.data(), {0, 1}, {}));
CHECK(!cursor.loadFromPixels(pixels.data(), {1, 0}, {}));
CHECK(cursor.loadFromPixels(pixels.data(), {1, 1}, {}));
}
2023-01-18 12:51:08 +08:00
SECTION("loadFromSystem()")
2023-02-12 09:58:49 +08:00
{
sf::Cursor cursor;
CHECK(cursor.loadFromSystem(sf::Cursor::Hand));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeHorizontal));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeVertical));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeLeft));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeRight));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTop));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottom));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTopLeft));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTopRight));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottomLeft));
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottomRight));
CHECK(cursor.loadFromSystem(sf::Cursor::Cross));
CHECK(cursor.loadFromSystem(sf::Cursor::Help));
CHECK(cursor.loadFromSystem(sf::Cursor::NotAllowed));
}
}