From 4c90416d40fa9397d690ea3e494fa73338efee86 Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Thu, 4 Dec 2003 21:52:52 +0000 Subject: [PATCH] More tests for {Local,Global}{,Re}Alloc() calls. Cleanup of the Heap*() tests. --- dlls/kernel/tests/heap.c | 63 +++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/dlls/kernel/tests/heap.c b/dlls/kernel/tests/heap.c index 7c2c58e5253..53a436ceb2b 100644 --- a/dlls/kernel/tests/heap.c +++ b/dlls/kernel/tests/heap.c @@ -21,24 +21,59 @@ #include #include -#include "ntstatus.h" #include "windef.h" #include "winbase.h" #include "wine/test.h" -#include "winnt.h" -#include "winnls.h" -#include "winreg.h" -#include "winternl.h" - -static void test_realloc( void ) -{ - void *mem = NULL; - - mem = HeapReAlloc(GetProcessHeap(), 0, mem, 10); - ok(mem == NULL, "memory allocated"); -} START_TEST(heap) { - test_realloc(); + void *mem; + HGLOBAL gbl; + SIZE_T size; + + /* Heap*() functions */ + mem = HeapAlloc(GetProcessHeap(), 0, 0); + ok(mem != NULL, "memory not allocated for size 0"); + + mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10); + ok(mem == NULL, "memory allocated by HeapReAlloc"); + + /* Global*() functions */ + gbl = GlobalAlloc(GMEM_MOVEABLE, 0); + ok(gbl != NULL, "global memory not allocated for size 0"); + + gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE); + ok(gbl != NULL, "Can't realloc global memory"); + size = GlobalSize(gbl); + ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld", size); + gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE); + ok(gbl == NULL, "GlobalReAlloc should fail on size 0, instead size=%ld", size); + size = GlobalSize(gbl); + ok(size == 0, "Memory not resized to size 0, instead size=%ld", size); + ok(GlobalFree(gbl) == NULL, "Memory not freed"); + size = GlobalSize(gbl); + ok(size == 0, "Memory should have been freed, size=%ld", size); + + gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE); + ok(gbl == NULL, "global realloc allocated memory"); + + /* Local*() functions */ + gbl = LocalAlloc(GMEM_MOVEABLE, 0); + ok(gbl != NULL, "global memory not allocated for size 0"); + + gbl = LocalReAlloc(gbl, 10, GMEM_MOVEABLE); + ok(gbl != NULL, "Can't realloc global memory"); + size = LocalSize(gbl); + ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld", size); + gbl = LocalReAlloc(gbl, 0, GMEM_MOVEABLE); + ok(gbl == NULL, "LocalReAlloc should fail on size 0, instead size=%ld", size); + size = LocalSize(gbl); + ok(size == 0, "Memory not resized to size 0, instead size=%ld", size); + ok(LocalFree(gbl) == NULL, "Memory not freed"); + size = LocalSize(gbl); + ok(size == 0, "Memory should have been freed, size=%ld", size); + + gbl = LocalReAlloc(0, 10, GMEM_MOVEABLE); + ok(gbl == NULL, "global realloc allocated memory"); + }