@@ -59,7 +59,7 @@ $RECYCLE.BIN/ | |||||
*.lnk | *.lnk | ||||
.idea/ | .idea/ | ||||
cmake-build-debug/ | cmake-build-debug/ | ||||
dependencies/ | |||||
/dependencies/ | |||||
assets_wip/ | assets_wip/ | ||||
Backup_*.cdr | Backup_*.cdr | ||||
.DS_Store | .DS_Store |
@@ -130,8 +130,8 @@ add_executable( | |||||
src/packages/game/data/IZ_list.h | src/packages/game/data/IZ_list.h | ||||
src/packages/net/svc/IZ_wsclient.c | src/packages/net/svc/IZ_wsclient.c | ||||
src/packages/net/svc/IZ_wsclient.h | src/packages/net/svc/IZ_wsclient.h | ||||
src/packages/log/IZ_intercept.c | |||||
src/packages/log/IZ_intercept.h | |||||
src/packages/log/IZ_intercept.c | |||||
src/packages/log/IZ_intercept.h | |||||
src/packages/midi/IZ_midi.c | src/packages/midi/IZ_midi.c | ||||
src/packages/midi/IZ_midi.h | src/packages/midi/IZ_midi.h | ||||
src/packages/net/core/IZ_websocket.h | src/packages/net/core/IZ_websocket.h | ||||
@@ -149,11 +149,18 @@ add_executable( | |||||
src/packages/game/IZ_app_config.h | src/packages/game/IZ_app_config.h | ||||
src/packages/game/asset/IZ_asset.c | src/packages/game/asset/IZ_asset.c | ||||
src/packages/game/asset/IZ_asset.h | src/packages/game/asset/IZ_asset.h | ||||
src/packages/stdinc/IZ_string.c | |||||
src/packages/stdinc/IZ_string.h | |||||
src/packages/stdinc/IZ_string.c | |||||
src/packages/stdinc/IZ_string.h | |||||
src/packages/io/IZ_io.c | src/packages/io/IZ_io.c | ||||
src/packages/io/IZ_io.h | src/packages/io/IZ_io.h | ||||
src/packages/log/IZ_log.c src/packages/log/IZ_log.h src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.h src/packages/compat/IZ_windows.h src/packages/stdinc/IZ_stdlib.c src/packages/stdinc/IZ_stdlib.h) | |||||
src/packages/log/IZ_log.c | |||||
src/packages/log/IZ_log.h | |||||
src/packages/timer/IZ_timer.c | |||||
src/packages/timer/IZ_timer.h | |||||
src/packages/compat/IZ_windows.h | |||||
src/packages/stdinc/IZ_stdlib.c | |||||
src/packages/stdinc/IZ_stdlib.h | |||||
) | |||||
if (WIN32) | if (WIN32) | ||||
target_link_libraries( | target_link_libraries( | ||||
@@ -200,12 +207,12 @@ add_executable( | |||||
src/packages/test/IZ_mock.h | src/packages/test/IZ_mock.h | ||||
src/packages/test/IZ_test.h | src/packages/test/IZ_test.h | ||||
__mocks__/minIni.mock.h | |||||
__mocks__/SDL_keyboard.mock.h | |||||
__mocks__/SDL_events.mock.h | |||||
__mocks__/SDL_joystick.mock.h | |||||
__mocks__/SDL_stdinc.mock.h | |||||
__mocks__/portmidi.mock.h | |||||
__mocks__/dependencies/minIni/minIni.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_keyboard.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_events.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_joystick.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_stdinc.mock.h | |||||
__mocks__/dependencies/portmidi/portmidi.mock.h | |||||
src/packages/config/IZ_config.h | src/packages/config/IZ_config.h | ||||
@@ -229,9 +236,9 @@ add_executable( | |||||
dependencies/bdd-for-c/bdd-for-c.h | dependencies/bdd-for-c/bdd-for-c.h | ||||
src/packages/test/IZ_mock.h | src/packages/test/IZ_mock.h | ||||
src/packages/test/IZ_test.h | src/packages/test/IZ_test.h | ||||
__mocks__/minIni.mock.h | |||||
__mocks__/SDL_stdinc.mock.h | |||||
__mocks__/SDL_render.mock.h | |||||
__mocks__/dependencies/minIni/minIni.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_stdinc.mock.h | |||||
__mocks__/dependencies/SDL2/SDL_render.mock.h | |||||
src/packages/config/IZ_config.h | src/packages/config/IZ_config.h | ||||
src/packages/game/output/video/IZ_video.h | src/packages/game/output/video/IZ_video.h | ||||
src/packages/game/output/video/IZ_video.c | src/packages/game/output/video/IZ_video.c | ||||
@@ -243,6 +250,14 @@ add_executable( | |||||
dependencies/bdd-for-c/bdd-for-c.h | dependencies/bdd-for-c/bdd-for-c.h | ||||
src/packages/test/IZ_mock.h | src/packages/test/IZ_mock.h | ||||
src/packages/test/IZ_test.h | src/packages/test/IZ_test.h | ||||
src/packages/timer/IZ_timer.h | |||||
src/packages/timer/IZ_timer.c | |||||
src/packages/stdinc/IZ_stdlib.h | |||||
__mocks__/src/packages/stdinc/IZ_stdlib.mock.h | |||||
src/packages/stdinc/IZ_string.h | |||||
__mocks__/src/packages/stdinc/IZ_string.mock.h | |||||
src/packages/log/IZ_log.h | |||||
__mocks__/src/packages/log/IZ_log.mock.h | |||||
src/packages/game/memory/IZ_pool.h | src/packages/game/memory/IZ_pool.h | ||||
src/packages/game/memory/IZ_pool.c | src/packages/game/memory/IZ_pool.c | ||||
src/packages/game/memory/memory.test.c | src/packages/game/memory/memory.test.c | ||||
@@ -250,6 +265,12 @@ add_executable( | |||||
src/packages/game/data/IZ_list.h | src/packages/game/data/IZ_list.h | ||||
) | ) | ||||
target_link_libraries( | |||||
game-test-memory | |||||
SDL2main | |||||
SDL2 | |||||
) | |||||
add_executable( | add_executable( | ||||
game-test-data | game-test-data | ||||
dependencies/bdd-for-c/bdd-for-c.h | dependencies/bdd-for-c/bdd-for-c.h | ||||
@@ -284,8 +305,8 @@ add_executable( | |||||
src/packages/server/db/IZ_repo.c | src/packages/server/db/IZ_repo.c | ||||
src/packages/server/db/IZ_repo.h | src/packages/server/db/IZ_repo.h | ||||
src/packages/server/IZ_subsystem.h | src/packages/server/IZ_subsystem.h | ||||
src/packages/stdinc/IZ_string.c | |||||
src/packages/stdinc/IZ_string.h | |||||
src/packages/stdinc/IZ_string.c | |||||
src/packages/stdinc/IZ_string.h | |||||
src/packages/io/IZ_io.c | src/packages/io/IZ_io.c | ||||
src/packages/io/IZ_io.h | src/packages/io/IZ_io.h | ||||
src/packages/log/IZ_log.c | src/packages/log/IZ_log.c | ||||
@@ -1,5 +1,6 @@ | |||||
- [X] Improve logging (remove SDL/lws dependency) | - [X] Improve logging (remove SDL/lws dependency) | ||||
- [X] Unify memset/memcpy/free/malloc functions (remove SDL/lws dependency) | - [X] Unify memset/memcpy/free/malloc functions (remove SDL/lws dependency) | ||||
- [ ] Implement memory pool | |||||
- [ ] Fix gamepad mapping | - [ ] Fix gamepad mapping | ||||
- [ ] Provide default mapping | - [ ] Provide default mapping | ||||
- [ ] Allow customization of button mappings | - [ ] Allow customization of button mappings | ||||
@@ -1,8 +1,8 @@ | |||||
#ifndef SDL_JOYSTICK_MOCK_H | #ifndef SDL_JOYSTICK_MOCK_H | ||||
#define SDL_JOYSTICK_MOCK_H | #define SDL_JOYSTICK_MOCK_H | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../src/packages/test/IZ_test.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/test/IZ_test.h" | |||||
typedef struct _SDL_Joystick {} SDL_Joystick; | typedef struct _SDL_Joystick {} SDL_Joystick; | ||||
@@ -1,8 +1,8 @@ | |||||
#ifndef SDL_KEYBOARD_MOCK_H | #ifndef SDL_KEYBOARD_MOCK_H | ||||
#define SDL_KEYBOARD_MOCK_H | #define SDL_KEYBOARD_MOCK_H | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../src/packages/test/IZ_test.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/test/IZ_test.h" | |||||
mock(SDL_GetKeyName) const char* SDL_GetKeyName(i32 key) { | mock(SDL_GetKeyName) const char* SDL_GetKeyName(i32 key) { | ||||
mock_return(SDL_GetKeyName) ""; | mock_return(SDL_GetKeyName) ""; |
@@ -1,8 +1,8 @@ | |||||
#ifndef SDL_RENDER_MOCK_H | #ifndef SDL_RENDER_MOCK_H | ||||
#define SDL_RENDER_MOCK_H | #define SDL_RENDER_MOCK_H | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../src/packages/test/IZ_test.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/test/IZ_test.h" | |||||
typedef struct SDL_Renderer SDL_Renderer; | typedef struct SDL_Renderer SDL_Renderer; | ||||
@@ -2,8 +2,8 @@ | |||||
#define SDL_STDINC_MOCK_H | #define SDL_STDINC_MOCK_H | ||||
#include <string.h> | #include <string.h> | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../src/packages/test/IZ_test.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/test/IZ_test.h" | |||||
mock(SDL_memcpy) void* SDL_memcpy(void* dst, const void* src, size_t len) { | mock(SDL_memcpy) void* SDL_memcpy(void* dst, const void* src, size_t len) { | ||||
mock_return(SDL_memcpy) memcpy(dst, src, len); | mock_return(SDL_memcpy) memcpy(dst, src, len); | ||||
@@ -21,4 +21,8 @@ mock(SDL_free) void SDL_free(void* mem) { | |||||
mock_return(SDL_free); | mock_return(SDL_free); | ||||
} | } | ||||
mock(SDL_calloc) void* SDL_calloc(size_t num, size_t size) { | |||||
mock_return(SDL_calloc) calloc(num, size); | |||||
} | |||||
#endif | #endif |
@@ -1,8 +1,8 @@ | |||||
#ifndef MININI_MOCK_H | #ifndef MININI_MOCK_H | ||||
#define MININI_MOCK_H | #define MININI_MOCK_H | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../src/packages/test/IZ_test.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/test/IZ_test.h" | |||||
mock(ini_getl) long ini_getl(const char *Section, const char *Key, long DefValue, const char *Filename) { | mock(ini_getl) long ini_getl(const char *Section, const char *Key, long DefValue, const char *Filename) { | ||||
mock_return(ini_getl) DefValue; | mock_return(ini_getl) DefValue; |
@@ -3,7 +3,7 @@ | |||||
#define PORTMIDI_INCLUDED | #define PORTMIDI_INCLUDED | ||||
#include "../src/packages/common/IZ_common.h" | |||||
#include "../../../src/packages/common/IZ_common.h" | |||||
typedef i32 PmDeviceID; | typedef i32 PmDeviceID; | ||||
typedef void PortMidiStream; | typedef void PortMidiStream; |
@@ -0,0 +1,11 @@ | |||||
#ifndef IZ_LOG_MOCK_H | |||||
#define IZ_LOG_MOCK_H | |||||
#include "../../../src/packages/log/IZ_log.h" | |||||
#include "../../../src/packages/test/IZ_mock.h" | |||||
mock(IZ_LogInfo) void IZ_LogInfo(IZ_LogCategory category, const char* format, ...) { | |||||
mock_return(IZ_LogInfo); | |||||
} | |||||
#endif |
@@ -0,0 +1,19 @@ | |||||
#ifndef IZ_STDLIB_MOCK_C | |||||
#define IZ_STDLIB_MOCK_C | |||||
#include <SDL_stdinc.h> | |||||
#include "../../../../src/packages/test/IZ_mock.h" | |||||
mock(IZ_malloc) void* IZ_malloc(size_t size) { | |||||
mock_return(IZ_malloc) SDL_malloc(size); | |||||
} | |||||
mock(IZ_free) void IZ_free(void* mem) { | |||||
mock_return(IZ_free) SDL_free(mem); | |||||
} | |||||
mock(IZ_calloc) void* IZ_calloc(unsigned int num, size_t size) { | |||||
mock_return(IZ_calloc) SDL_calloc(num, size); | |||||
} | |||||
#endif |
@@ -0,0 +1,10 @@ | |||||
#ifndef IZ_STRING_MOCK_C | |||||
#define IZ_STRING_MOCK_C | |||||
#include "../../../../src/packages/test/IZ_mock.h" | |||||
mock(IZ_memset) void* IZ_memset(void* dst, int c, size_t len) { | |||||
mock_return(IZ_memset) 0; | |||||
} | |||||
#endif |
@@ -346,14 +346,14 @@ IZ_ConfigInitializeResult IZ_ConfigInitialize(IZ_ConfigItem item[], const char* | |||||
IZ_ConfigLoad(item, config_path); | IZ_ConfigLoad(item, config_path); | ||||
IZ_ConfigSaveResult save_result = IZ_ConfigSave(item, config_path); | IZ_ConfigSaveResult save_result = IZ_ConfigSave(item, config_path); | ||||
if (save_result < 0) { | if (save_result < 0) { | ||||
IZ_LogError("Config sync failed! Result: %u", save_result); | |||||
IZ_LogError("app/config Sync failed! Result: %u", save_result); | |||||
return IZ_CONFIG_INITIALIZE_RESULT_ERROR; | return IZ_CONFIG_INITIALIZE_RESULT_ERROR; | ||||
} | } | ||||
IZ_ConfigOverride(item, argc, argv); | IZ_ConfigOverride(item, argc, argv); | ||||
if (save_result > 0) { | if (save_result > 0) { | ||||
IZ_LogWarn(false, "Config sync encountered issues. Result: %u", save_result); | |||||
IZ_LogWarn(false, "app/config Sync encountered issues. Result: %u", save_result); | |||||
return IZ_CONFIG_INITIALIZE_RESULT_WARNING; | return IZ_CONFIG_INITIALIZE_RESULT_WARNING; | ||||
} | } | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Config sync successful."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/config Sync successful."); | |||||
return IZ_CONFIG_INITIALIZE_RESULT_OK; | return IZ_CONFIG_INITIALIZE_RESULT_OK; | ||||
} | } |
@@ -28,7 +28,7 @@ typedef enum { | |||||
IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* argv[]) { | IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* argv[]) { | ||||
IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Starting %s...", IZ_APP_NAME); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/global Starting %s...", IZ_APP_NAME); | |||||
IZ_memset(app, 0, sizeof(struct IZ_App)); | IZ_memset(app, 0, sizeof(struct IZ_App)); | ||||
const char* cmdline_buffer; | const char* cmdline_buffer; | ||||
@@ -47,7 +47,7 @@ IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* | |||||
); | ); | ||||
if (SDL_Init(flags) < 0) { | if (SDL_Init(flags) < 0) { | ||||
IZ_LogError("Framework initialization failed! Reason: %s", SDL_GetError()); | |||||
IZ_LogError("app/global Framework initialization failed! Reason: %s", SDL_GetError()); | |||||
return IZ_APP_INITIALIZE_RESULT_SDL_ERROR; | return IZ_APP_INITIALIZE_RESULT_SDL_ERROR; | ||||
} | } | ||||
@@ -70,12 +70,12 @@ IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* | |||||
} | } | ||||
void IZ_AppTeardown(struct IZ_App* app) { | void IZ_AppTeardown(struct IZ_App* app) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Shutting down networking..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/net Shutting down..."); | |||||
IZ_NetClientDisconnect(&app->net_state); | IZ_NetClientDisconnect(&app->net_state); | ||||
IZ_PoolTeardown(&app->pool); | IZ_PoolTeardown(&app->pool); | ||||
IZ_InputTeardown(&app->input_state); | IZ_InputTeardown(&app->input_state); | ||||
IZ_VideoTeardown(&app->video_state); | IZ_VideoTeardown(&app->video_state); | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Stopping %s...", IZ_APP_NAME); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/global Stopping %s...", IZ_APP_NAME); | |||||
SDL_Quit(); | SDL_Quit(); | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
#include "../../test/IZ_test.h" | #include "../../test/IZ_test.h" | ||||
#include "../../common/IZ_common.h" | #include "../../common/IZ_common.h" | ||||
#include "../../../__mocks__/SDL_stdinc.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_stdinc.mock.h" | |||||
#include "IZ_list.h" | #include "IZ_list.h" | ||||
bool NodeExists(IZ_ListNode** node, u64 _index, IZ_List* list) { | bool NodeExists(IZ_ListNode** node, u64 _index, IZ_List* list) { | ||||
@@ -10,7 +10,7 @@ void IZ_InputHandlePortMIDIEvents(IZ_InputState* state, PmEvent e) { | |||||
} | } | ||||
IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_path, u8 argc, const char* argv[]) { | IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_path, u8 argc, const char* argv[]) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Setting up input..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Setting up..."); | |||||
*state = (IZ_InputState) { | *state = (IZ_InputState) { | ||||
.action = {}, | .action = {}, | ||||
@@ -40,13 +40,13 @@ IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_p | |||||
IZ_ProcedureResult final_result = -result; | IZ_ProcedureResult final_result = -result; | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Input setup complete. Result: %d", final_result); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Setup complete. Result: %d", final_result); | |||||
return final_result; | return final_result; | ||||
} | } | ||||
void IZ_InputTeardown(IZ_InputState* state) { | void IZ_InputTeardown(IZ_InputState* state) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Shutting down input..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Shutting down..."); | |||||
IZ_JoystickTeardown(&state->joystick_state); | IZ_JoystickTeardown(&state->joystick_state); | ||||
IZ_MIDIInputTeardown(&state->midi_input_state); | IZ_MIDIInputTeardown(&state->midi_input_state); | ||||
} | } |
@@ -1,8 +1,8 @@ | |||||
#include "../../../__mocks__/SDL_keyboard.mock.h" | |||||
#include "../../../__mocks__/SDL_joystick.mock.h" | |||||
#include "../../../__mocks__/SDL_stdinc.mock.h" | |||||
#include "../../../__mocks__/minIni.mock.h" | |||||
#include "../../../__mocks__/portmidi.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_keyboard.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_joystick.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_stdinc.mock.h" | |||||
#include "../../../../__mocks__/dependencies/minIni/minIni.mock.h" | |||||
#include "../../../../__mocks__/dependencies/portmidi/portmidi.mock.h" | |||||
//#include "../../stdinc/IZ_string.h" | //#include "../../stdinc/IZ_string.h" | ||||
#include "IZ_keyboard.h" | #include "IZ_keyboard.h" | ||||
#include "IZ_joystick.h" | #include "IZ_joystick.h" | ||||
@@ -1,7 +1,7 @@ | |||||
#include "IZ_pool.h" | #include "IZ_pool.h" | ||||
void IZ_PoolInitialize(IZ_Pool* pool, size_t size) { | void IZ_PoolInitialize(IZ_Pool* pool, size_t size) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Setting up memory pools..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/memory Setting up pool..."); | |||||
IZ_ListInitialize(&pool->items); | IZ_ListInitialize(&pool->items); | ||||
pool->memory = IZ_malloc(size); | pool->memory = IZ_malloc(size); | ||||
IZ_memset(pool->memory, 0, size); | IZ_memset(pool->memory, 0, size); | ||||
@@ -47,7 +47,7 @@ void IZ_PoolDeallocate(IZ_PoolItem* item) { | |||||
} | } | ||||
void IZ_PoolTeardown(IZ_Pool* pool) { | void IZ_PoolTeardown(IZ_Pool* pool) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Shutting down memory pools..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/memory Shutting down pool..."); | |||||
IZ_free(pool->memory); | IZ_free(pool->memory); | ||||
pool->memory = NULL; | pool->memory = NULL; | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
#include "../../test/IZ_test.h" | |||||
#include "../../../__mocks__/SDL_stdinc.mock.h" | |||||
#include <bdd-for-c.h> | |||||
#include "../../../../__mocks__/src/packages/log/IZ_log.mock.h" | |||||
#include "../../../../__mocks__/src/packages/stdinc/IZ_stdlib.mock.h" | |||||
#include "../../../../__mocks__/src/packages/stdinc/IZ_string.mock.h" | |||||
#include "IZ_pool.h" | #include "IZ_pool.h" | ||||
struct DummyInnerStruct { | struct DummyInnerStruct { | ||||
@@ -21,11 +23,11 @@ spec("memory") { | |||||
static IZ_Pool pool; | static IZ_Pool pool; | ||||
after_each() { | after_each() { | ||||
mock_reset(SDL_memset); | |||||
mock_reset(IZ_memset); | |||||
} | } | ||||
after_each() { | after_each() { | ||||
mock_reset(SDL_malloc); | |||||
mock_reset(IZ_malloc); | |||||
} | } | ||||
after_each() { | after_each() { | ||||
@@ -33,12 +35,12 @@ spec("memory") { | |||||
} | } | ||||
it("initializes the pool values") { | it("initializes the pool values") { | ||||
mock_set_expected_calls(SDL_memset, 1); | |||||
mock_set_expected_calls(IZ_memset, 1); | |||||
IZ_PoolInitialize(&pool, POOL_MAX_SIZE); | IZ_PoolInitialize(&pool, POOL_MAX_SIZE); | ||||
check( | check( | ||||
mock_get_expected_calls(SDL_memset) == mock_get_actual_calls(SDL_memset), | |||||
mock_get_expected_calls(IZ_memset) == mock_get_actual_calls(IZ_memset), | |||||
"Call count mismatch." | "Call count mismatch." | ||||
); | ); | ||||
} | } | ||||
@@ -47,7 +49,7 @@ spec("memory") { | |||||
IZ_PoolInitialize(&pool, POOL_MAX_SIZE); | IZ_PoolInitialize(&pool, POOL_MAX_SIZE); | ||||
check( | check( | ||||
mock_is_called(SDL_malloc), | |||||
mock_is_called(IZ_malloc), | |||||
"Memory not allocated." | "Memory not allocated." | ||||
); | ); | ||||
} | } | ||||
@@ -172,14 +174,14 @@ spec("memory") { | |||||
} | } | ||||
after_each() { | after_each() { | ||||
mock_reset(SDL_free); | |||||
mock_reset(IZ_free); | |||||
} | } | ||||
it("frees memory") { | it("frees memory") { | ||||
IZ_PoolTeardown(&pool); | IZ_PoolTeardown(&pool); | ||||
check( | check( | ||||
mock_is_called(SDL_free), | |||||
mock_is_called(IZ_free), | |||||
"Memory not freed." | "Memory not freed." | ||||
); | ); | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
#include "../../../__mocks__/minIni.mock.h" | |||||
#include "../../../__mocks__/SDL_stdinc.mock.h" | |||||
#include "../../../__mocks__/SDL_render.mock.h" | |||||
#include "../../../../__mocks__/dependencies/minIni/minIni.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_stdinc.mock.h" | |||||
#include "../../../../__mocks__/dependencies/SDL2/SDL_render.mock.h" | |||||
#include "video/IZ_video.h" | #include "video/IZ_video.h" | ||||
const char* IZ_ConfigGetCommandlineOption(u8 argc, const char* argv[], const char* val) { | const char* IZ_ConfigGetCommandlineOption(u8 argc, const char* argv[], const char* val) { | ||||
@@ -65,7 +65,7 @@ IZ_ProcedureResult IZ_VideoInitializeConfig(IZ_VideoState* state, const char* c | |||||
} | } | ||||
IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, const char* config_path, u8 argc, const char* argv[]) { | IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, const char* config_path, u8 argc, const char* argv[]) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Setting up video..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/video Setting up..."); | |||||
IZ_memcpy(state, sizeof(IZ_VideoState), &IZ_VIDEO_DEFAULT_STATE, sizeof(IZ_VideoState)); | IZ_memcpy(state, sizeof(IZ_VideoState), &IZ_VIDEO_DEFAULT_STATE, sizeof(IZ_VideoState)); | ||||
IZ_memset(state->active_sprites, 0, sizeof(IZ_SpriteSlot) * IZ_MAX_ACTIVE_SPRITES); | IZ_memset(state->active_sprites, 0, sizeof(IZ_SpriteSlot) * IZ_MAX_ACTIVE_SPRITES); | ||||
if (IZ_VideoInitializeConfig(state, config_path, argc, argv) < 0) { | if (IZ_VideoInitializeConfig(state, config_path, argc, argv) < 0) { | ||||
@@ -84,7 +84,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con | |||||
SDL_WINDOW_SHOWN | SDL_WINDOW_SHOWN | ||||
); | ); | ||||
if (window == NULL) { | if (window == NULL) { | ||||
IZ_LogError("Window could not be created! Reason: %s", SDL_GetError()); | |||||
IZ_LogError("app/video Window could not be created! Reason: %s", SDL_GetError()); | |||||
return -3; | return -3; | ||||
} | } | ||||
state->window = window; | state->window = window; | ||||
@@ -93,7 +93,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con | |||||
} | } | ||||
void IZ_VideoTeardown(IZ_VideoState* state) { | void IZ_VideoTeardown(IZ_VideoState* state) { | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Shutting down video..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/video Shutting down..."); | |||||
for (u16 i = 0; i < IZ_MAX_ACTIVE_SPRITES; i += 1) { | for (u16 i = 0; i < IZ_MAX_ACTIVE_SPRITES; i += 1) { | ||||
if (state->active_sprites[i].sprite.texture) { | if (state->active_sprites[i].sprite.texture) { | ||||
SDL_DestroyTexture(state->active_sprites[i].sprite.texture); | SDL_DestroyTexture(state->active_sprites[i].sprite.texture); | ||||
@@ -56,20 +56,20 @@ void IZ_LogInterceptHandleFromWS(i32 level, const char* line) { | |||||
switch (level) { | switch (level) { | ||||
// TODO level is a bit field...check if each level is OR'd. | // TODO level is a bit field...check if each level is OR'd. | ||||
case LLL_ERR: | case LLL_ERR: | ||||
IZ_LogError("ws %s", buffer); | |||||
IZ_LogError("app/net/ws %s", buffer); | |||||
return; | return; | ||||
case LLL_WARN: | case LLL_WARN: | ||||
IZ_LogWarn(false, "ws %s", buffer); | |||||
IZ_LogWarn(false, "app/net/ws %s", buffer); | |||||
return; | return; | ||||
case LLL_NOTICE: | case LLL_NOTICE: | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GENERIC, "ws %s", buffer); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GENERIC, "app/net/ws %s", buffer); | |||||
return; | return; | ||||
case LLL_USER: | case LLL_USER: | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
IZ_Log("ws %s", buffer); | |||||
IZ_Log("app/net/ws %s", buffer); | |||||
} | } | ||||
void IZ_LogInterceptWSMessages(i32 level) { | void IZ_LogInterceptWSMessages(i32 level) { | ||||
@@ -106,7 +106,7 @@ IZ_ProcedureResult IZ_NetClientInitialize( | |||||
if (!user_data) { | if (!user_data) { | ||||
return -1; | return -1; | ||||
} | } | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "Setting up networking..."); | |||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/net Setting up..."); | |||||
IZ_memcpy(state, sizeof(IZ_NetClientState), &IZ_NET_CLIENT_DEFAULT_STATE, sizeof(IZ_NetClientState)); | IZ_memcpy(state, sizeof(IZ_NetClientState), &IZ_NET_CLIENT_DEFAULT_STATE, sizeof(IZ_NetClientState)); | ||||
if (IZ_NetClientInitializeConfig(state, config_path, argc, argv) < 0) { | if (IZ_NetClientInitializeConfig(state, config_path, argc, argv) < 0) { | ||||
return -2; | return -2; | ||||