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 void run_apibuf_tests(void)
38 /* test normal logic */
39 ok(NetApiBufferAllocate(1024, &p
) == NERR_Success
,
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
,
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");
63 ok(NetApiBufferAllocate(0, &p
) == NERR_Success
,
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");
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());