mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 13:53:36 +02:00
Add more tests for the Window module
This commit is contained in:
1 parent
02d6d4937a
commit
d971aada83
6 files changed
+114
-1
No files matched your search
+5
-1
@@ -34,8 +34,12 @@ catch_discover_tests(test-csfml-system)
|
||||
|
||||
add_executable(test-csfml-window
|
||||
Window/Joystick.test.cpp
|
||||
Window/Keyboard.test.cpp
|
||||
Window/Mouse.test.cpp
|
||||
Window/Sensor.test.cpp
|
||||
Window/WindowBase.test.cpp
|
||||
)
|
||||
target_link_libraries(test-csfml-window PRIVATE csfml-window Catch2::Catch2WithMain)
|
||||
target_link_libraries(test-csfml-window PRIVATE csfml-window Catch2::Catch2WithMain SFML::Window)
|
||||
set_target_warnings(test-csfml-window)
|
||||
catch_discover_tests(test-csfml-window)
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <CSFML/Window/Joystick.h>
|
||||
|
||||
#include <SFML/Window/Joystick.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators_range.hpp>
|
||||
|
||||
@@ -12,6 +14,18 @@ TEST_CASE("[Window] sfJoystick")
|
||||
STATIC_CHECK(sfJoystickAxisCount == 8);
|
||||
}
|
||||
|
||||
SECTION("sfJoystickAxis")
|
||||
{
|
||||
STATIC_CHECK(sfJoystickX == static_cast<int>(sf::Joystick::Axis::X));
|
||||
STATIC_CHECK(sfJoystickY == static_cast<int>(sf::Joystick::Axis::Y));
|
||||
STATIC_CHECK(sfJoystickZ == static_cast<int>(sf::Joystick::Axis::Z));
|
||||
STATIC_CHECK(sfJoystickR == static_cast<int>(sf::Joystick::Axis::R));
|
||||
STATIC_CHECK(sfJoystickU == static_cast<int>(sf::Joystick::Axis::U));
|
||||
STATIC_CHECK(sfJoystickV == static_cast<int>(sf::Joystick::Axis::V));
|
||||
STATIC_CHECK(sfJoystickPovX == static_cast<int>(sf::Joystick::Axis::PovX));
|
||||
STATIC_CHECK(sfJoystickPovY == static_cast<int>(sf::Joystick::Axis::PovY));
|
||||
}
|
||||
|
||||
// By avoiding calling sfJoystick_update() we can guarantee that
|
||||
// no joysticks will be detected. This is how we can ensure these
|
||||
// tests are portable and reliable.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <CSFML/Window/Keyboard.h>
|
||||
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Window] sfKeyboard")
|
||||
{
|
||||
SECTION("sfKeyCode")
|
||||
{
|
||||
STATIC_CHECK(sfKeyUnknown == static_cast<int>(sf::Keyboard::Key::Unknown));
|
||||
STATIC_CHECK(sfKeyA == static_cast<int>(sf::Keyboard::Key::A));
|
||||
STATIC_CHECK(sfKeyB == static_cast<int>(sf::Keyboard::Key::B));
|
||||
STATIC_CHECK(sfKeyC == static_cast<int>(sf::Keyboard::Key::C));
|
||||
STATIC_CHECK(sfKeyD == static_cast<int>(sf::Keyboard::Key::D));
|
||||
STATIC_CHECK(sfKeyPause == static_cast<int>(sf::Keyboard::Key::Pause));
|
||||
STATIC_CHECK(sfKeyCount == sf::Keyboard::KeyCount);
|
||||
}
|
||||
|
||||
SECTION("sfScancode")
|
||||
{
|
||||
STATIC_CHECK(sfScanUnknown == static_cast<int>(sf::Keyboard::Scan::Unknown));
|
||||
STATIC_CHECK(sfScanA == static_cast<int>(sf::Keyboard::Scan::A));
|
||||
STATIC_CHECK(sfScanB == static_cast<int>(sf::Keyboard::Scan::B));
|
||||
STATIC_CHECK(sfScanC == static_cast<int>(sf::Keyboard::Scan::C));
|
||||
STATIC_CHECK(sfScanD == static_cast<int>(sf::Keyboard::Scan::D));
|
||||
STATIC_CHECK(sfScancodeCount == sf::Keyboard::ScancodeCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <CSFML/Window/Mouse.h>
|
||||
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Window] sfMouse")
|
||||
{
|
||||
SECTION("sfMouseButton")
|
||||
{
|
||||
STATIC_CHECK(sfMouseLeft == static_cast<int>(sf::Mouse::Button::Left));
|
||||
STATIC_CHECK(sfMouseRight == static_cast<int>(sf::Mouse::Button::Right));
|
||||
STATIC_CHECK(sfMouseMiddle == static_cast<int>(sf::Mouse::Button::Middle));
|
||||
STATIC_CHECK(sfMouseXButton1 == static_cast<int>(sf::Mouse::Button::Extra1));
|
||||
STATIC_CHECK(sfMouseXButton2 == static_cast<int>(sf::Mouse::Button::Extra2));
|
||||
STATIC_CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount);
|
||||
}
|
||||
|
||||
SECTION("sfMouseWheel")
|
||||
{
|
||||
STATIC_CHECK(sfMouseHorizontalWheel == static_cast<int>(sf::Mouse::Wheel::Horizontal));
|
||||
STATIC_CHECK(sfMouseVerticalWheel == static_cast<int>(sf::Mouse::Wheel::Vertical));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <CSFML/Window/Sensor.h>
|
||||
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Window] sfSensor")
|
||||
{
|
||||
SECTION("sfSensorType")
|
||||
{
|
||||
STATIC_CHECK(sfSensorAccelerometer == static_cast<int>(sf::Sensor::Type::Accelerometer));
|
||||
STATIC_CHECK(sfSensorGyroscope == static_cast<int>(sf::Sensor::Type::Gyroscope));
|
||||
STATIC_CHECK(sfSensorMagnetometer == static_cast<int>(sf::Sensor::Type::Magnetometer));
|
||||
STATIC_CHECK(sfSensorGravity == static_cast<int>(sf::Sensor::Type::Gravity));
|
||||
STATIC_CHECK(sfSensorUserAcceleration == static_cast<int>(sf::Sensor::Type::UserAcceleration));
|
||||
STATIC_CHECK(sfSensorOrientation == static_cast<int>(sf::Sensor::Type::Orientation));
|
||||
STATIC_CHECK(sfSensorCount == sf::Sensor::Count);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <CSFML/Window/WindowBase.h>
|
||||
|
||||
#include <SFML/Window/WindowBase.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Window] sfWindowBase")
|
||||
{
|
||||
SECTION("sfWindowStyle")
|
||||
{
|
||||
STATIC_CHECK(sfNone == static_cast<int>(sf::Style::None));
|
||||
STATIC_CHECK(sfTitlebar == static_cast<int>(sf::Style::Titlebar));
|
||||
STATIC_CHECK(sfResize == static_cast<int>(sf::Style::Resize));
|
||||
STATIC_CHECK(sfClose == static_cast<int>(sf::Style::Close));
|
||||
STATIC_CHECK(sfDefaultStyle == static_cast<int>(sf::Style::Default));
|
||||
}
|
||||
|
||||
SECTION("sfWindowState")
|
||||
{
|
||||
STATIC_CHECK(sfWindowed == static_cast<int>(sf::State::Windowed));
|
||||
STATIC_CHECK(sfFullscreen == static_cast<int>(sf::State::Fullscreen));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user