heap: more tests

Dimitrie O. Paun dpaun at rogers.com
Thu Dec 4 13:59:19 CST 2003


ChangeLog
    More tests for {Local,Global}{,Re}Alloc() calls.
    Cleanup of the Heap*() tests.

Index: dlls/kernel/tests/heap.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/tests/heap.c,v
retrieving revision 1.1
diff -u -r1.1 heap.c
--- dlls/kernel/tests/heap.c	25 Nov 2003 01:02:02 -0000	1.1
+++ dlls/kernel/tests/heap.c	4 Dec 2003 19:34:57 -0000
@@ -21,24 +21,59 @@
 #include <stdarg.h>
 #include <stdlib.h>
 
-#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 )
+START_TEST(heap)
 {
-    void *mem = NULL;
+    void *mem;
+    HGLOBAL gbl;
+    SIZE_T size;
 
-    mem = HeapReAlloc(GetProcessHeap(), 0, mem, 10);
-    ok(mem == NULL, "memory allocated");
-}
+    /* 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");
 
-START_TEST(heap)
-{
-    test_realloc();
 }


-- 
Dimi.




More information about the wine-patches mailing list