2 * Unit test suite for heap functions
4 * Copyright 2003 Dimitrie O. Paun
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/test.h"
34 /* Heap*() functions */
35 mem = HeapAlloc(GetProcessHeap(), 0, 0);
36 ok(mem != NULL, "memory not allocated for size 0\n");
38 mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10);
39 ok(mem == NULL, "memory allocated by HeapReAlloc\n");
41 for (size = 0; size <= 256; size++)
44 mem = HeapAlloc(GetProcessHeap(), 0, size);
45 heap_size = HeapSize(GetProcessHeap(), 0, mem);
46 ok(size == heap_size, "HeapSize returned %lu instead of %lu\n", heap_size, size);
47 HeapFree(GetProcessHeap(), 0, mem);
50 /* Global*() functions */
51 gbl = GlobalAlloc(GMEM_MOVEABLE, 0);
52 ok(gbl != NULL, "global memory not allocated for size 0\n");
54 gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
55 ok(gbl != NULL, "Can't realloc global memory\n");
56 size = GlobalSize(gbl);
57 ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
61 gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
62 ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
65 size = GlobalSize(gbl);
66 ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
67 ok(GlobalFree(gbl) == NULL, "Memory not freed\n");
68 size = GlobalSize(gbl);
69 ok(size == 0, "Memory should have been freed, size=%ld\n", size);
71 gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
72 ok(gbl == NULL, "global realloc allocated memory\n");
74 /* Local*() functions */
75 gbl = LocalAlloc(LMEM_MOVEABLE, 0);
76 ok(gbl != NULL, "local memory not allocated for size 0\n");
78 gbl = LocalReAlloc(gbl, 10, LMEM_MOVEABLE);
79 ok(gbl != NULL, "Can't realloc local memory\n");
80 size = LocalSize(gbl);
81 ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
85 gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
86 ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
89 size = LocalSize(gbl);
90 ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
91 ok(LocalFree(gbl) == NULL, "Memory not freed\n");
92 size = LocalSize(gbl);
93 ok(size == 0, "Memory should have been freed, size=%ld\n", size);
95 gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
96 ok(gbl == NULL, "local realloc allocated memory\n");