@@ -5,6 +5,8 @@
#include "../../../../__mocks__/dependencies/minIni/minIni.mock.h"
#include "../../../../__mocks__/dependencies/portmidi/portmidi.mock.h"
#include "../../../../__mocks__/src/packages/stdinc/IZ_string.mock.h"
#include "../../../../__mocks__/src/packages/stdinc/IZ_stdlib.mock.h"
#include "../../../../__mocks__/src/packages/config/IZ_config.mock.h"
#include "IZ_keyboard.h"
#include "IZ_joystick.h"
#include "IZ_midi.h"
@@ -35,11 +37,11 @@ spec("input") {
}
after_each() {
mock_reset(ini_putl );
mock_reset(IZ_ConfigSave );
}
after_each() {
mock_reset(ini_ge tl);
mock_reset(IZ_Conf igI nitia lize );
}
it("sets initial state") {
@@ -50,29 +52,15 @@ spec("input") {
}
it("calls load method") {
mock_set_expected_calls(ini_getl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
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)
);
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called.");
}
it("calls save method") {
mock_set_expected_calls(ini_putl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
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)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
it("opens device handles") {
@@ -339,7 +327,7 @@ spec("input") {
static IZ_JoystickState state[IZ_PLAYERS];
after_each() {
mock_reset(ini_putl );
mock_reset(IZ_ConfigSave );
}
before_each() {
@@ -351,26 +339,19 @@ spec("input") {
}
it("calls save method") {
mock_set_expected_calls(ini_putl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);
IZ_JoystickSaveConfig(&state, IZ_CONFIG_GAME_PATH);
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)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
}
describe("Teardown") {
static SDL_Joystick device ;
static void* device = (void*) 1;
static IZ_JoystickState state[IZ_PLAYERS] = {};
before_each() {
for (u8 p = 0; p < IZ_PLAYERS; p += 1) {
state[p].device = & device;
state[p].device = device;
}
}
@@ -402,11 +383,11 @@ spec("input") {
// }
after_each() {
mock_reset(ini_gets );
mock_reset(IZ_ConfigInitialize );
}
after_each() {
mock_reset(ini_puts );
mock_reset(IZ_ConfigSave );
}
before_each() {
@@ -424,29 +405,15 @@ spec("input") {
}
it("calls load method") {
mock_set_expected_calls(ini_gets, IZ_CONTROLS * IZ_PLAYERS);
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
check(
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets),
"Call count mismatch for ini_gets() (expected %u, received %u).",
mock_get_expected_calls(ini_gets),
mock_get_actual_calls(ini_gets)
);
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called.");
}
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
"Call count mismatch for ini_puts() (expected %u, received %u).",
mock_get_expected_calls(ini_puts),
mock_get_actual_calls(ini_puts)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
}
@@ -492,7 +459,7 @@ spec("input") {
static IZ_KeyboardState state[IZ_PLAYERS] = {};
after_each() {
mock_reset(ini_puts );
mock_reset(IZ_ConfigSave );
}
before_each() {
@@ -504,16 +471,9 @@ spec("input") {
}
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
IZ_KeyboardSaveConfig(IZ_CONFIG_GAME_PATH, &state);
IZ_KeyboardSaveConfig(&state, IZ_CONFIG_GAME_PATH);
check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
"Call count mismatch for ini_puts() (expected %u, received %u).",
mock_get_expected_calls(ini_puts),
mock_get_actual_calls(ini_puts)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
}
}
@@ -535,19 +495,19 @@ spec("input") {
}
after_each() {
mock_reset(ini_puts );
mock_reset(IZ_ConfigSave );
}
after_each() {
mock_reset(ini_gets );
mock_reset(IZ_ConfigInitialize );
}
after_each() {
mock_reset(ini_putl );
mock_reset(IZ_ConfigSave );
}
after_each() {
mock_reset(ini_ge tl);
mock_reset(IZ_Conf igI nitia lize );
}
it("sets initial state") {
@@ -558,45 +518,15 @@ spec("input") {
}
it("calls load method") {
mock_set_expected_calls(ini_gets, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_getl, 2 * IZ_PLAYERS);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
check(
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets),
"Call count mismatch for ini_gets() (expected %u, received %u).",
mock_get_expected_calls(ini_gets),
mock_get_actual_calls(ini_gets)
);
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)
);
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called.");
}
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_putl, 2 * IZ_PLAYERS);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);
check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
"Call count mismatch for ini_puts() (expected %u, received %u).",
mock_get_expected_calls(ini_puts),
mock_get_actual_calls(ini_puts)
);
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)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
it("opens device handles") {
@@ -617,32 +547,17 @@ spec("input") {
static IZ_MIDIInputState state[IZ_PLAYERS];
after_each() {
mock_reset(ini_puts );
mock_reset(IZ_ConfigSave );
}
after_each() {
mock_reset(ini_putl );
mock_reset(IZ_ConfigSave );
}
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_putl, 2 * IZ_PLAYERS);
IZ_MIDIInputSaveConfig(&state, IZ_CONFIG_GAME_PATH);
IZ_MIDIInputSaveConfig(IZ_CONFIG_GAME_PATH, &state);
check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
"Call count mismatch for ini_puts() (expected %u, received %u).",
mock_get_expected_calls(ini_puts),
mock_get_actual_calls(ini_puts)
);
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)
);
check(mock_is_called(IZ_ConfigSave), "Config save function not called.");
}
}