Add trailing '\n's to ok() calls.
[wine.git] / dlls / netapi32 / tests / apibuf.c
blob03f25543b113eceeaafc40d9b015f1cf46adbf99
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 NET_API_STATUS (WINAPI *pNetApiBufferAllocate)(DWORD,LPVOID*)=NULL;
33 static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL;
34 static NET_API_STATUS (WINAPI *pNetApiBufferReallocate)(LPVOID,DWORD,LPVOID*)=NULL;
35 static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL;
38 void run_apibuf_tests(void)
40 VOID *p;
41 DWORD dwSize;
43 if (!pNetApiBufferAllocate)
44 return;
46 /* test normal logic */
47 ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success,
48 "Reserved memory\n");
49 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
50 ok(dwSize >= 1024, "The size is correct\n");
52 ok(pNetApiBufferReallocate(p, 1500, (LPVOID *) &p) == NERR_Success,
53 "Reallocated\n");
54 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
55 ok(dwSize >= 1500, "The size is correct\n");
57 ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
59 /* test errors handling */
60 ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
62 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
63 ok(dwSize >= 0, "The size\n");
64 ok(pNetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n");
66 /* border reallocate cases */
67 ok(pNetApiBufferReallocate(0, 1500, (LPVOID *) &p) != NERR_Success, "(Re)allocated\n");
68 ok(p == NULL, "Some memory got allocated\n");
69 ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success, "Memory not reserved\n");
70 ok(pNetApiBufferReallocate(p, 0, (LPVOID *) &p) == NERR_Success, "Not freed\n");
71 ok(p == NULL, "Pointer not cleared\n");
73 /* 0-length buffer */
74 ok(pNetApiBufferAllocate(0, (LPVOID *)&p) == NERR_Success,
75 "Reserved memory\n");
76 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
77 ok((dwSize >= 0) && (dwSize < 0xFFFFFFFF),"The size of the 0-length buffer\n");
78 ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
81 START_TEST(apibuf)
83 HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
84 pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate");
85 pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
86 pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate");
87 pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
88 if (!pNetApiBufferSize)
89 trace("It appears there is no netapi32 functionality on this platform\n");
91 run_apibuf_tests();