Correct the test for the ODS_SELECTED bit in the WM_DRAWITEM message
[wine] / dlls / kernel / tests / heap.c
1 /*
2  * Unit test suite for heap functions
3  *
4  * Copyright 2003 Dimitrie O. Paun
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <stdlib.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wine/test.h"
27
28 START_TEST(heap)
29 {
30     void *mem;
31     HGLOBAL gbl;
32     SIZE_T size;
33
34     /* Heap*() functions */
35     mem = HeapAlloc(GetProcessHeap(), 0, 0);
36     ok(mem != NULL, "memory not allocated for size 0");
37
38     mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10);
39     ok(mem == NULL, "memory allocated by HeapReAlloc");
40
41     /* Global*() functions */
42     gbl = GlobalAlloc(GMEM_MOVEABLE, 0);
43     ok(gbl != NULL, "global memory not allocated for size 0");
44
45     gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
46     ok(gbl != NULL, "Can't realloc global memory");
47     size = GlobalSize(gbl);
48     ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld", size);
49     gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
50     ok(gbl == NULL, "GlobalReAlloc should fail on size 0, instead size=%ld", size);
51     size = GlobalSize(gbl);
52     ok(size == 0, "Memory not resized to size 0, instead size=%ld", size);
53     ok(GlobalFree(gbl) == NULL, "Memory not freed");
54     size = GlobalSize(gbl);
55     ok(size == 0, "Memory should have been freed, size=%ld", size);
56
57     gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
58     ok(gbl == NULL, "global realloc allocated memory");
59
60     /* Local*() functions */
61     gbl = LocalAlloc(GMEM_MOVEABLE, 0);
62     ok(gbl != NULL, "global memory not allocated for size 0");
63
64     gbl = LocalReAlloc(gbl, 10, GMEM_MOVEABLE);
65     ok(gbl != NULL, "Can't realloc global memory");
66     size = LocalSize(gbl);
67     ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld", size);
68     gbl = LocalReAlloc(gbl, 0, GMEM_MOVEABLE);
69     ok(gbl == NULL, "LocalReAlloc should fail on size 0, instead size=%ld", size);
70     size = LocalSize(gbl);
71     ok(size == 0, "Memory not resized to size 0, instead size=%ld", size);
72     ok(LocalFree(gbl) == NULL, "Memory not freed");
73     size = LocalSize(gbl);
74     ok(size == 0, "Memory should have been freed, size=%ld", size);
75
76     gbl = LocalReAlloc(0, 10, GMEM_MOVEABLE);
77     ok(gbl == NULL, "global realloc allocated memory");
78
79 }