2003-11-25 02:02:02 +01:00
|
|
|
/*
|
|
|
|
* Unit test suite for heap functions
|
|
|
|
*
|
|
|
|
* Copyright 2003 Dimitrie O. Paun
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2003-12-04 22:52:52 +01:00
|
|
|
START_TEST(heap)
|
2003-11-25 02:02:02 +01:00
|
|
|
{
|
2003-12-04 22:52:52 +01:00
|
|
|
void *mem;
|
|
|
|
HGLOBAL gbl;
|
|
|
|
SIZE_T size;
|
2003-11-25 02:02:02 +01:00
|
|
|
|
2003-12-04 22:52:52 +01:00
|
|
|
/* Heap*() functions */
|
|
|
|
mem = HeapAlloc(GetProcessHeap(), 0, 0);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(mem != NULL, "memory not allocated for size 0\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
|
|
|
|
mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(mem == NULL, "memory allocated by HeapReAlloc\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
|
|
|
|
/* Global*() functions */
|
|
|
|
gbl = GlobalAlloc(GMEM_MOVEABLE, 0);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "global memory not allocated for size 0\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
|
|
|
|
gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "Can't realloc global memory\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
size = GlobalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
|
2003-12-15 20:51:17 +01:00
|
|
|
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
|
2003-12-15 20:51:17 +01:00
|
|
|
}
|
|
|
|
|
2003-12-04 22:52:52 +01:00
|
|
|
size = GlobalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
|
|
|
|
ok(GlobalFree(gbl) == NULL, "Memory not freed\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
size = GlobalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
|
2003-12-04 22:52:52 +01:00
|
|
|
|
|
|
|
gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl == NULL, "global realloc allocated memory\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
|
|
|
|
/* Local*() functions */
|
2005-03-17 21:53:37 +01:00
|
|
|
gbl = LocalAlloc(LMEM_MOVEABLE, 0);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "local memory not allocated for size 0\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
|
2005-03-17 21:53:37 +01:00
|
|
|
gbl = LocalReAlloc(gbl, 10, LMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "Can't realloc local memory\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
size = LocalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
|
2003-12-15 20:51:17 +01:00
|
|
|
|
|
|
|
todo_wine
|
|
|
|
{
|
2005-03-17 21:53:37 +01:00
|
|
|
gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
|
2003-12-15 20:51:17 +01:00
|
|
|
}
|
|
|
|
|
2003-12-04 22:52:52 +01:00
|
|
|
size = LocalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
|
|
|
|
ok(LocalFree(gbl) == NULL, "Memory not freed\n");
|
2003-12-04 22:52:52 +01:00
|
|
|
size = LocalSize(gbl);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(size == 0, "Memory should have been freed, size=%ld\n", size);
|
2003-12-04 22:52:52 +01:00
|
|
|
|
2005-03-17 21:53:37 +01:00
|
|
|
gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(gbl == NULL, "local realloc allocated memory\n");
|
2003-11-25 02:02:02 +01:00
|
|
|
|
|
|
|
}
|