|
- #include "bdd-for-c.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") {
- describe("LoadConfig") {
- 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") {
- 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(
- config.video.width == 640,
- "Default value for Video.Width is not loaded."
- );
- check(
- config.video.height == 480,
- "Default value for Video.Height is not loaded."
- );
- check(
- config.video.max_fps == 30,
- "Default value for Video.MaxFps is not loaded."
- );
-
- check(
- config.input.gamepad_axis_threshold == 8000,
- "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
- );
- }
- }
- }
|