libwine: Remove __wine_main_arg* from the public header.
[wine/zf.git] / dlls / netapi32 / tests / apibuf.c
blob9063a4f6c55aef9c80db5c4afa80332c91af5e2e
1 /*
2 * Copyright 2002 Andriy Palamarchuk
4 * Conformance test of the network buffer function.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "wine/test.h"
24 #include <windef.h>
25 #include <winbase.h>
26 #include <winerror.h>
27 #include <lmcons.h>
28 #include <lmerr.h>
29 #include <lmapibuf.h>
30 #include <lmaccess.h>
32 static void run_apibuf_tests(void)
34 VOID *p;
35 DWORD dwSize;
36 NET_API_STATUS res;
38 /* test normal logic */
39 ok(NetApiBufferAllocate(1024, &p) == NERR_Success,
40 "Reserved memory\n");
41 ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
42 ok(dwSize >= 1024, "The size is correct\n");
44 ok(NetApiBufferReallocate(p, 1500, &p) == NERR_Success,
45 "Reallocated\n");
46 ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
47 ok(dwSize >= 1500, "The size is correct\n");
49 ok(NetApiBufferFree(p) == NERR_Success, "Freed\n");
51 ok(NetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n");
53 /* border reallocate cases */
54 ok(NetApiBufferReallocate(0, 1500, &p) == NERR_Success, "Reallocate with OldBuffer = NULL failed\n");
55 ok(p != NULL, "No memory got allocated\n");
56 ok(NetApiBufferFree(p) == NERR_Success, "NetApiBufferFree failed\n");
58 ok(NetApiBufferAllocate(1024, &p) == NERR_Success, "Memory not reserved\n");
59 ok(NetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n");
60 ok(p == NULL, "Pointer not cleared\n");
62 /* 0-length buffer */
63 ok(NetApiBufferAllocate(0, &p) == NERR_Success,
64 "Reserved memory\n");
65 ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
66 ok(dwSize < 0xFFFFFFFF, "The size of the 0-length buffer\n");
67 ok(NetApiBufferFree(p) == NERR_Success, "Freed\n");
69 /* NULL-Pointer */
70 /* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */
71 SetLastError(0xdeadbeef);
72 res = NetApiBufferAllocate(0, NULL);
73 ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef),
74 "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with "
75 "0xdeadbeef)\n", res, GetLastError());
77 SetLastError(0xdeadbeef);
78 res = NetApiBufferAllocate(1024, NULL);
79 ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef),
80 "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with "
81 "0xdeadbeef)\n", res, GetLastError());
84 START_TEST(apibuf)
86 run_apibuf_tests();