@@ -62,7 +62,7 @@ add_executable( | |||
src/packages/game/output/IZ_video.h | |||
src/packages/game/output/IZ_video.c | |||
src/packages/game/output/IZ_video.test.c | |||
src/packages/game/output/output.test.c | |||
) | |||
add_executable( | |||
@@ -5,13 +5,14 @@ void IZ_HandleJoystickDeviceEvents(SDL_Event e, IZ_JoystickState* state) { | |||
if (SDL_NumJoysticks() <= PLAYERS && !state->joystick_instance) { | |||
state->joystick_instance = SDL_JoystickOpen(e.jdevice.which); | |||
} | |||
return; | |||
} | |||
if (e.type == SDL_JOYDEVICEREMOVED) { | |||
if ( | |||
state->joystick_instance | |||
&& SDL_JoystickInstanceID(state->joystick_instance) == e.jdevice.which | |||
) { | |||
) { | |||
state->joystick_instance = NULL; | |||
} | |||
} | |||
@@ -70,12 +71,12 @@ void IZ_HandleJoystickButtonEvents(SDL_Event e, IZ_JoystickState* state, IZ_Acti | |||
if (e.type == SDL_JOYBUTTONDOWN) { | |||
*action |= bitflag; | |||
break; | |||
return; | |||
} | |||
if (e.type == SDL_JOYBUTTONUP) { | |||
*action &= ~bitflag; | |||
break; | |||
return; | |||
} | |||
} | |||
} | |||
@@ -6,11 +6,11 @@ void IZ_HandleKeyboardEvents(SDL_Event e, IZ_KeyboardState* state, IZ_Action* ac | |||
const uint16_t bitflag = (0x1 << i); | |||
if (e.type == SDL_KEYDOWN) { | |||
*action |= bitflag; | |||
break; | |||
return; | |||
} | |||
if (e.type == SDL_KEYUP) { | |||
*action &= ~bitflag; | |||
break; | |||
return; | |||
} | |||
} | |||
} | |||
@@ -1,66 +0,0 @@ | |||
#include "../../../__mocks__/minIni.mock.h" | |||
#include "../__mocks__/IZ_config.mock.h" | |||
#include "IZ_video.h" | |||
spec("output/video") { | |||
describe("LoadVideoConfig") { | |||
static IZ_VideoConfig config; | |||
after_each() { | |||
mock_reset(IZ_GetConfigPath); | |||
} | |||
after_each() { | |||
mock_reset(ini_getl); | |||
} | |||
it("calls load method") { | |||
mock_set_expected_calls(ini_getl, 3); | |||
IZ_LoadVideoConfig(&config); | |||
check( | |||
mock_is_called(IZ_GetConfigPath), | |||
"SDL_GetBasePath() not called." | |||
); | |||
check( | |||
mock_get_expected_calls(ini_getl) == mock_get_actual_calls(ini_getl), | |||
"Call count mismatch for ini_getl() (expected %u, received %u).", | |||
mock_get_expected_calls(ini_getl), | |||
mock_get_actual_calls(ini_getl) | |||
); | |||
} | |||
} | |||
describe("SaveVideoConfig") { | |||
static IZ_VideoConfig config; | |||
after_each() { | |||
mock_reset(IZ_GetConfigPath); | |||
} | |||
after_each() { | |||
mock_reset(ini_putl); | |||
} | |||
before_each() { | |||
config.width = 1337; | |||
config.height = 420; | |||
config.max_fps = 69; | |||
} | |||
it("calls save method") { | |||
mock_set_expected_calls(ini_putl, 3); | |||
IZ_SaveVideoConfig(&config); | |||
check( | |||
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl), | |||
"Call count mismatch for ini_putl() (expected %u, received %u).", | |||
mock_get_expected_calls(ini_putl), | |||
mock_get_actual_calls(ini_putl) | |||
); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
#include "../../../__mocks__/minIni.mock.h" | |||
#include "../__mocks__/IZ_config.mock.h" | |||
#include "IZ_video.h" | |||
spec("output") { | |||
describe("video") { | |||
describe("LoadVideoConfig") { | |||
static IZ_VideoConfig config; | |||
after_each() { | |||
mock_reset(IZ_GetConfigPath); | |||
} | |||
after_each() { | |||
mock_reset(ini_getl); | |||
} | |||
it("calls load method") { | |||
mock_set_expected_calls(ini_getl, 3); | |||
IZ_LoadVideoConfig(&config); | |||
check( | |||
mock_is_called(IZ_GetConfigPath), | |||
"SDL_GetBasePath() not called." | |||
); | |||
check( | |||
mock_get_expected_calls(ini_getl) == mock_get_actual_calls(ini_getl), | |||
"Call count mismatch for ini_getl() (expected %u, received %u).", | |||
mock_get_expected_calls(ini_getl), | |||
mock_get_actual_calls(ini_getl) | |||
); | |||
} | |||
} | |||
describe("SaveVideoConfig") { | |||
static IZ_VideoConfig config; | |||
after_each() { | |||
mock_reset(IZ_GetConfigPath); | |||
} | |||
after_each() { | |||
mock_reset(ini_putl); | |||
} | |||
before_each() { | |||
config.width = 1337; | |||
config.height = 420; | |||
config.max_fps = 69; | |||
} | |||
it("calls save method") { | |||
mock_set_expected_calls(ini_putl, 3); | |||
IZ_SaveVideoConfig(&config); | |||
check( | |||
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl), | |||
"Call count mismatch for ini_putl() (expected %u, received %u).", | |||
mock_get_expected_calls(ini_putl), | |||
mock_get_actual_calls(ini_putl) | |||
); | |||
} | |||
} | |||
} | |||
} |