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
23 #include "wine/test.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 static void run_apibuf_tests(void)
44 if (!pNetApiBufferAllocate
)
47 /* test normal logic */
48 ok(pNetApiBufferAllocate(1024, (LPVOID
*)&p
) == NERR_Success
,
50 ok(pNetApiBufferSize(p
, &dwSize
) == NERR_Success
, "Got size\n");
51 ok(dwSize
>= 1024, "The size is correct\n");
53 ok(pNetApiBufferReallocate(p
, 1500, (LPVOID
*) &p
) == NERR_Success
,
55 ok(pNetApiBufferSize(p
, &dwSize
) == NERR_Success
, "Got size\n");
56 ok(dwSize
>= 1500, "The size is correct\n");
58 ok(pNetApiBufferFree(p
) == NERR_Success
, "Freed\n");
60 /* test errors handling */
61 ok(pNetApiBufferFree(p
) == NERR_Success
, "Freed\n");
63 ok(pNetApiBufferSize(p
, &dwSize
) == NERR_Success
, "Got size\n");
64 ok(dwSize
>= 0, "The size\n");
65 ok(pNetApiBufferSize(NULL
, &dwSize
) == ERROR_INVALID_PARAMETER
, "Error for NULL pointer\n");
67 /* border reallocate cases */
68 ok(pNetApiBufferReallocate(0, 1500, (LPVOID
*) &p
) == NERR_Success
, "Reallocate with OldBuffer = NULL failed\n");
69 ok(p
!= NULL
, "No memory got allocated\n");
70 ok(pNetApiBufferAllocate(1024, (LPVOID
*)&p
) == NERR_Success
, "Memory not reserved\n");
71 ok(pNetApiBufferReallocate(p
, 0, (LPVOID
*) &p
) == NERR_Success
, "Not freed\n");
72 ok(p
== NULL
, "Pointer not cleared\n");
75 ok(pNetApiBufferAllocate(0, (LPVOID
*)&p
) == NERR_Success
,
77 ok(pNetApiBufferSize(p
, &dwSize
) == NERR_Success
, "Got size\n");
78 ok((dwSize
>= 0) && (dwSize
< 0xFFFFFFFF),"The size of the 0-length buffer\n");
79 ok(pNetApiBufferFree(p
) == NERR_Success
, "Freed\n");
82 /* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */
83 SetLastError(0xdeadbeef);
84 res
= pNetApiBufferAllocate(0, (LPVOID
*)NULL
);
85 ok( (res
== ERROR_INVALID_PARAMETER
) && (GetLastError() == 0xdeadbeef),
86 "returned %ld with 0x%lx (expected ERROR_INVALID_PARAMETER with " \
87 "0xdeadbeef)\n", res
, GetLastError());
89 SetLastError(0xdeadbeef);
90 res
= pNetApiBufferAllocate(1024, (LPVOID
*)NULL
);
91 ok( (res
== ERROR_INVALID_PARAMETER
) && (GetLastError() == 0xdeadbeef),
92 "returned %ld with 0x%lx (expected ERROR_INVALID_PARAMETER with " \
93 "0xdeadbeef)\n", res
, GetLastError());
98 HMODULE hnetapi32
=LoadLibraryA("netapi32.dll");
99 pNetApiBufferAllocate
=(void*)GetProcAddress(hnetapi32
,"NetApiBufferAllocate");
100 pNetApiBufferFree
=(void*)GetProcAddress(hnetapi32
,"NetApiBufferFree");
101 pNetApiBufferReallocate
=(void*)GetProcAddress(hnetapi32
,"NetApiBufferReallocate");
102 pNetApiBufferSize
=(void*)GetProcAddress(hnetapi32
,"NetApiBufferSize");
103 if (!pNetApiBufferSize
)
104 trace("It appears there is no netapi32 functionality on this platform\n");