mirror of
https://github.com/gperftools/gperftools
synced 2025-02-18 05:06:55 +00:00
added basic unit test for singular malloc hooks
This commit is contained in:
parent
bce72dda07
commit
51b0ad55b3
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user