Skip to content

Commit 828e6ba

Browse files
committed
Add tests for sfCursor
1 parent ab1a1a2 commit 828e6ba

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ set_target_warnings(test-csfml-system)
3333
catch_discover_tests(test-csfml-system)
3434

3535
add_executable(test-csfml-window
36+
Window/Cursor.test.cpp
3637
Window/Joystick.test.cpp
3738
Window/Keyboard.test.cpp
3839
Window/Mouse.test.cpp

test/Window/Cursor.test.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <CSFML/Window/Cursor.h>
2+
3+
#include <SFML/Window/Cursor.hpp>
4+
5+
#include <catch2/catch_test_macros.hpp>
6+
7+
#include <array>
8+
9+
TEST_CASE("[Window] sfCursor")
10+
{
11+
SECTION("sfCursorType")
12+
{
13+
STATIC_CHECK(sfCursorArrow == static_cast<int>(sf::Cursor::Type::Arrow));
14+
STATIC_CHECK(sfCursorArrowWait == static_cast<int>(sf::Cursor::Type::ArrowWait));
15+
STATIC_CHECK(sfCursorWait == static_cast<int>(sf::Cursor::Type::Wait));
16+
STATIC_CHECK(sfCursorText == static_cast<int>(sf::Cursor::Type::Text));
17+
STATIC_CHECK(sfCursorHand == static_cast<int>(sf::Cursor::Type::Hand));
18+
STATIC_CHECK(sfCursorSizeHorizontal == static_cast<int>(sf::Cursor::Type::SizeHorizontal));
19+
STATIC_CHECK(sfCursorSizeVertical == static_cast<int>(sf::Cursor::Type::SizeVertical));
20+
STATIC_CHECK(sfCursorSizeTopLeftBottomRight == static_cast<int>(sf::Cursor::Type::SizeTopLeftBottomRight));
21+
STATIC_CHECK(sfCursorSizeBottomLeftTopRight == static_cast<int>(sf::Cursor::Type::SizeBottomLeftTopRight));
22+
STATIC_CHECK(sfCursorSizeLeft == static_cast<int>(sf::Cursor::Type::SizeLeft));
23+
STATIC_CHECK(sfCursorSizeRight == static_cast<int>(sf::Cursor::Type::SizeRight));
24+
STATIC_CHECK(sfCursorSizeTop == static_cast<int>(sf::Cursor::Type::SizeTop));
25+
STATIC_CHECK(sfCursorSizeBottom == static_cast<int>(sf::Cursor::Type::SizeBottom));
26+
STATIC_CHECK(sfCursorSizeTopLeft == static_cast<int>(sf::Cursor::Type::SizeTopLeft));
27+
STATIC_CHECK(sfCursorSizeBottomRight == static_cast<int>(sf::Cursor::Type::SizeBottomRight));
28+
STATIC_CHECK(sfCursorSizeBottomLeft == static_cast<int>(sf::Cursor::Type::SizeBottomLeft));
29+
STATIC_CHECK(sfCursorSizeTopRight == static_cast<int>(sf::Cursor::Type::SizeTopRight));
30+
STATIC_CHECK(sfCursorSizeAll == static_cast<int>(sf::Cursor::Type::SizeAll));
31+
STATIC_CHECK(sfCursorCross == static_cast<int>(sf::Cursor::Type::Cross));
32+
STATIC_CHECK(sfCursorHelp == static_cast<int>(sf::Cursor::Type::Help));
33+
STATIC_CHECK(sfCursorNotAllowed == static_cast<int>(sf::Cursor::Type::NotAllowed));
34+
}
35+
36+
SECTION("sfCursor_createFromPixels")
37+
{
38+
static constexpr std::array<std::uint8_t, 4> pixels{};
39+
sfCursor* cursor = sfCursor_createFromPixels(pixels.data(), {1, 1}, {});
40+
CHECK(cursor);
41+
sfCursor_destroy(cursor);
42+
}
43+
44+
SECTION("sfCursor_createFromSystem")
45+
{
46+
sfCursor* cursor{};
47+
48+
SECTION("sfCursorArrow")
49+
{
50+
cursor = sfCursor_createFromSystem(sfCursorArrow);
51+
}
52+
53+
SECTION("sfCursorArrowWait")
54+
{
55+
cursor = sfCursor_createFromSystem(sfCursorArrowWait);
56+
}
57+
58+
SECTION("sfCursorWait")
59+
{
60+
cursor = sfCursor_createFromSystem(sfCursorWait);
61+
}
62+
63+
CHECK(cursor);
64+
sfCursor_destroy(cursor);
65+
}
66+
}

0 commit comments

Comments
 (0)