2016-11-18 01:56:42 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2018-12-09 22:43:42 +01:00
|
|
|
#include <GameInput.hpp>
|
|
|
|
#include <engine/GameInputState.hpp>
|
|
|
|
|
2016-11-18 01:56:42 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE(InputTests)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestStateUpdate) {
|
|
|
|
BOOST_CHECK(GameInputState::Handbrake != GameInputState::Submission);
|
|
|
|
BOOST_CHECK(GameInputState::Jump != GameInputState::Sprint);
|
|
|
|
{
|
|
|
|
// Currently tests against hard-coded input
|
|
|
|
GameInputState state;
|
|
|
|
|
|
|
|
SDL_Event ev;
|
|
|
|
ev.type = SDL_KEYDOWN;
|
|
|
|
ev.key.keysym.sym = SDLK_SPACE;
|
|
|
|
|
|
|
|
GameInput::updateGameInputState(&state, ev);
|
|
|
|
|
|
|
|
// Check that the correct inputs report pressed
|
|
|
|
for (int c = 0; c < GameInputState::_MaxControls; ++c) {
|
2018-07-27 22:53:35 +02:00
|
|
|
switch (static_cast<GameInputState::Control>(c)) {
|
2016-11-18 01:56:42 +01:00
|
|
|
case GameInputState::Jump:
|
|
|
|
case GameInputState::Handbrake:
|
2018-07-27 22:53:35 +02:00
|
|
|
BOOST_CHECK(
|
|
|
|
state.pressed(static_cast<GameInputState::Control>(c)));
|
2016-11-18 01:56:42 +01:00
|
|
|
break;
|
|
|
|
default:
|
2018-07-27 22:53:35 +02:00
|
|
|
BOOST_CHECK(!state.pressed(
|
|
|
|
static_cast<GameInputState::Control>(c)));
|
2016-11-18 01:56:42 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|