|
@@ -1,13 +1,91 @@ |
|
|
#include "bdd-for-c.h" |
|
|
#include "bdd-for-c.h" |
|
|
#include "../../game/config/IZ_config.h" |
|
|
#include "../../game/config/IZ_config.h" |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t calls_SDL_GetBasePath = 0; |
|
|
|
|
|
char* SDL_GetBasePath() { |
|
|
|
|
|
calls_SDL_GetBasePath += 1; |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t calls_SDL_GetKeyName = 0; |
|
|
|
|
|
const char* SDL_GetKeyName(SDL_KeyCode code) { |
|
|
|
|
|
calls_SDL_GetKeyName += 1; |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t calls_SDL_GetKeyFromName = 0; |
|
|
|
|
|
SDL_KeyCode SDL_GetKeyFromName(const char* name) { |
|
|
|
|
|
calls_SDL_GetKeyFromName += 1; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t calls_ini_gets = 0; |
|
|
|
|
|
int ini_gets( |
|
|
|
|
|
const char *Section, |
|
|
|
|
|
const char *Key, |
|
|
|
|
|
const char *DefValue, |
|
|
|
|
|
char *Buffer, |
|
|
|
|
|
int BufferSize, |
|
|
|
|
|
const char *Filename |
|
|
|
|
|
) { |
|
|
|
|
|
calls_ini_gets += 1; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t calls_ini_getl = 0; |
|
|
|
|
|
long ini_getl( |
|
|
|
|
|
const TCHAR *Section, |
|
|
|
|
|
const TCHAR *Key, |
|
|
|
|
|
long DefValue, |
|
|
|
|
|
const TCHAR *Filename |
|
|
|
|
|
) { |
|
|
|
|
|
calls_ini_getl += 1; |
|
|
|
|
|
return DefValue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
spec("config") { |
|
|
spec("config") { |
|
|
describe("LoadConfig") { |
|
|
describe("LoadConfig") { |
|
|
static IZ_Config config; |
|
|
static IZ_Config config; |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
calls_ini_getl = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
calls_ini_gets = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
calls_SDL_GetKeyFromName = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
calls_SDL_GetKeyName = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
calls_SDL_GetBasePath = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
it("should load default config values") { |
|
|
it("should load default config values") { |
|
|
IZ_LoadConfig(&config); |
|
|
IZ_LoadConfig(&config); |
|
|
|
|
|
|
|
|
|
|
|
check( |
|
|
|
|
|
calls_SDL_GetBasePath > 0, |
|
|
|
|
|
"SDL_GetBasePath() not called." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
static const int expected_calls_ini_getl = |
|
|
|
|
|
3 // video params |
|
|
|
|
|
+ 1 // input params |
|
|
|
|
|
+ (12 * PLAYERS); // joystick controls |
|
|
|
|
|
check( |
|
|
|
|
|
calls_ini_getl == expected_calls_ini_getl, |
|
|
|
|
|
"Call count mismatch for ini_getl() (expected %u, received %u).", |
|
|
|
|
|
expected_calls_ini_getl, |
|
|
|
|
|
calls_ini_getl |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
check( |
|
|
check( |
|
|
config.video.width == 640, |
|
|
config.video.width == 640, |
|
|
"Default value for Video.Width is not loaded." |
|
|
"Default value for Video.Width is not loaded." |
|
@@ -25,6 +103,33 @@ spec("config") { |
|
|
config.input.gamepad_axis_threshold == 8000, |
|
|
config.input.gamepad_axis_threshold == 8000, |
|
|
"Default value for Input.GamepadAxisThreshold is not loaded." |
|
|
"Default value for Input.GamepadAxisThreshold is not loaded." |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
static const int expected_calls_ini_gets = |
|
|
|
|
|
(16 * PLAYERS); // keyboard controls |
|
|
|
|
|
check( |
|
|
|
|
|
calls_ini_gets == expected_calls_ini_gets, |
|
|
|
|
|
"Call count mismatch for ini_gets() (expected %u, received %u).", |
|
|
|
|
|
expected_calls_ini_gets, |
|
|
|
|
|
calls_ini_gets |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
static const int expected_calls_SDL_GetKeyFromName = |
|
|
|
|
|
(16 * PLAYERS); // keyboard controls |
|
|
|
|
|
check( |
|
|
|
|
|
calls_SDL_GetKeyFromName == expected_calls_SDL_GetKeyFromName, |
|
|
|
|
|
"Call count mismatch for SDL_GetKeyFromName() (expected %u, received %u).", |
|
|
|
|
|
expected_calls_SDL_GetKeyFromName, |
|
|
|
|
|
calls_SDL_GetKeyFromName |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
static const int expected_calls_SDL_GetKeyName = |
|
|
|
|
|
(16 * PLAYERS); // keyboard controls |
|
|
|
|
|
check( |
|
|
|
|
|
calls_SDL_GetKeyName == expected_calls_SDL_GetKeyName, |
|
|
|
|
|
"Call count mismatch for SDL_GetKeyName() (expected %u, received %u).", |
|
|
|
|
|
expected_calls_SDL_GetKeyName, |
|
|
|
|
|
calls_SDL_GetKeyName |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |