Use modes for list teardown calls to prevent pollution of the tracked calls.master
@@ -9,7 +9,7 @@ mock_modes(IZ_LogInfo) { | |||||
IZ_LOG_INFO_LOG, | IZ_LOG_INFO_LOG, | ||||
}; | }; | ||||
mock(IZ_LogInfo) void IZ_LogInfo(IZ_LogCategory category, const char* fmt, ...) { | |||||
mock(IZ_LogInfo) void IZ_LogInfo(IZ_LogCategory category, const char* context, const char* fmt, ...) { | |||||
mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_SUPPRESS) { | mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_SUPPRESS) { | ||||
mock_return(IZ_LogInfo); | mock_return(IZ_LogInfo); | ||||
} else mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_LOG) { | } else mock_mode_if(IZ_LogInfo, IZ_LOG_INFO_LOG) { | ||||
@@ -8,8 +8,17 @@ mock(IZ_malloc) void* IZ_malloc(size_t size) { | |||||
mock_return(IZ_malloc) SDL_malloc(size); | mock_return(IZ_malloc) SDL_malloc(size); | ||||
} | } | ||||
mock_modes(IZ_free) { | |||||
IZ_FREE_CALLS_TRACKED = 0, | |||||
IZ_FREE_CALLS_UNTRACKED, | |||||
}; | |||||
mock(IZ_free) void IZ_free(void* mem) { | mock(IZ_free) void IZ_free(void* mem) { | ||||
mock_return(IZ_free) SDL_free(mem); | |||||
mock_mode_if(IZ_free, IZ_FREE_CALLS_TRACKED) { | |||||
mock_return(IZ_free) SDL_free(mem); | |||||
} else mock_mode_if(IZ_free, IZ_FREE_CALLS_UNTRACKED) { | |||||
SDL_free(mem); | |||||
} | |||||
} | } | ||||
mock(IZ_calloc) void* IZ_calloc(unsigned int num, size_t size) { | mock(IZ_calloc) void* IZ_calloc(unsigned int num, size_t size) { | ||||
@@ -21,8 +21,8 @@ spec("data") { | |||||
static IZ_List list; | static IZ_List list; | ||||
after_each() { | after_each() { | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); | |||||
IZ_ListTeardown(&list); | IZ_ListTeardown(&list); | ||||
mock_reset(IZ_free); | |||||
} | } | ||||
it("sets root to NULL") { | it("sets root to NULL") { | ||||
@@ -47,6 +47,8 @@ spec("data") { | |||||
IZ_ListAppendNode(&list, &value1); | IZ_ListAppendNode(&list, &value1); | ||||
IZ_ListAppendNode(&list, &value2); | IZ_ListAppendNode(&list, &value2); | ||||
IZ_ListAppendNode(&list, &value3); | IZ_ListAppendNode(&list, &value3); | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_TRACKED); | |||||
} | } | ||||
after_each() { | after_each() { | ||||
@@ -93,10 +95,12 @@ spec("data") { | |||||
} | } | ||||
after_each() { | after_each() { | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); | |||||
IZ_ListTeardown(&list); | IZ_ListTeardown(&list); | ||||
} | } | ||||
after_each() { | after_each() { | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); | |||||
IZ_ListTeardown(&list2); | IZ_ListTeardown(&list2); | ||||
} | } | ||||
@@ -139,6 +143,7 @@ spec("data") { | |||||
} | } | ||||
after_each() { | after_each() { | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_UNTRACKED); | |||||
IZ_ListTeardown(&list); | IZ_ListTeardown(&list); | ||||
} | } | ||||
@@ -167,6 +172,8 @@ spec("data") { | |||||
IZ_ListAppendNode(&list, &value1); | IZ_ListAppendNode(&list, &value1); | ||||
IZ_ListAppendNode(&list, &value2); | IZ_ListAppendNode(&list, &value2); | ||||
IZ_ListAppendNode(&list, &value3); | IZ_ListAppendNode(&list, &value3); | ||||
mock_mode(IZ_free, IZ_FREE_CALLS_TRACKED); | |||||
} | } | ||||
after_each() { | after_each() { | ||||
@@ -43,7 +43,10 @@ bool IZ_PoolGetSameItem(IZ_ListNode** node, u64 _index, IZ_List* list) { | |||||
} | } | ||||
void IZ_PoolDeallocate(IZ_PoolItem* item) { | void IZ_PoolDeallocate(IZ_PoolItem* item) { | ||||
IZ_ListDeleteNode(&item->pool->items, IZ_PoolGetSameItem); | |||||
IZ_ListNode** node = IZ_ListFindFirstNode(&item->pool->items, IZ_PoolGetSameItem); | |||||
if (node) { | |||||
IZ_ListDeleteNode(*node); | |||||
} | |||||
} | } | ||||
void IZ_PoolTeardown(IZ_Pool* pool) { | void IZ_PoolTeardown(IZ_Pool* pool) { | ||||