added basic unit test for singular malloc hooks

This commit is contained in:
Aliaksey Kandratsenka 2014-11-09 17:36:49 -08:00
parent bce72dda07
commit 51b0ad55b3

View File

@ -104,6 +104,28 @@ void TestMallocHook(void) {
if (!MallocHook_RemoveDeleteHook(&TestDeleteHook)) {
FAIL("Failed to remove delete hook");
}
free(forced_malloc(10));
free(forced_malloc(20));
if (g_new_hook_calls != 2) {
FAIL("Wrong number of calls to the new hook");
}
MallocHook_SetNewHook(&TestNewHook);
MallocHook_SetDeleteHook(&TestDeleteHook);
free(forced_malloc(10));
free(forced_malloc(20));
if (g_new_hook_calls != 4) {
FAIL("Wrong number of calls to the singular new hook");
}
if (MallocHook_SetNewHook(NULL) == NULL) {
FAIL("Failed to set new hook");
}
if (MallocHook_SetDeleteHook(NULL) == NULL) {
FAIL("Failed to set delete hook");
}
}
void TestMallocExtension(void) {