ReactOS 0.4.15-dev-7906-g1b85a5f
apibuf.c File Reference
#include <stdarg.h>
#include "wine/test.h"
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <lmcons.h>
#include <lmerr.h>
#include <lmapibuf.h>
#include <lmaccess.h>
Include dependency graph for apibuf.c:

Go to the source code of this file.

Functions

static NET_API_STATUS (WINAPI *pNetApiBufferAllocate)(DWORD
 
static void run_apibuf_tests (void)
 
 START_TEST (apibuf)
 

Variables

static DWORD
 
static LPVOID *static LPDWORD =NULL
 

Function Documentation

◆ NET_API_STATUS()

static NET_API_STATUS ( WINAPI pNetApiBufferAllocate)
static

◆ run_apibuf_tests()

static void run_apibuf_tests ( void  )
static

Definition at line 38 of file apibuf.c.

39{
40 VOID *p;
43
44 /* test normal logic */
45 ok(pNetApiBufferAllocate(1024, &p) == NERR_Success,
46 "Reserved memory\n");
47 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
48 ok(dwSize >= 1024, "The size is correct\n");
49
50 ok(pNetApiBufferReallocate(p, 1500, &p) == NERR_Success,
51 "Reallocated\n");
52 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
53 ok(dwSize >= 1500, "The size is correct\n");
54
55 ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
56
57 ok(pNetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n");
58
59 /* border reallocate cases */
60 ok(pNetApiBufferReallocate(0, 1500, &p) == NERR_Success, "Reallocate with OldBuffer = NULL failed\n");
61 ok(p != NULL, "No memory got allocated\n");
62 ok(pNetApiBufferFree(p) == NERR_Success, "NetApiBufferFree failed\n");
63
64 ok(pNetApiBufferAllocate(1024, &p) == NERR_Success, "Memory not reserved\n");
65 ok(pNetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n");
66 ok(p == NULL, "Pointer not cleared\n");
67
68 /* 0-length buffer */
69 ok(pNetApiBufferAllocate(0, &p) == NERR_Success,
70 "Reserved memory\n");
71 ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
72 ok(dwSize < 0xFFFFFFFF, "The size of the 0-length buffer\n");
73 ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
74
75 /* NULL-Pointer */
76 /* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */
77 SetLastError(0xdeadbeef);
78 res = pNetApiBufferAllocate(0, 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());
82
83 SetLastError(0xdeadbeef);
84 res = pNetApiBufferAllocate(1024, NULL);
85 ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef),
86 "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with "
87 "0xdeadbeef)\n", res, GetLastError());
88}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902
#define NERR_Success
Definition: lmerr.h:5
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( apibuf  )

Definition at line 90 of file apibuf.c.

91{
92 HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
93
94 pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate");
95 pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
96 pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate");
97 pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
98
99 if (pNetApiBufferAllocate && pNetApiBufferFree && pNetApiBufferReallocate && pNetApiBufferSize)
101 else
102 win_skip("Needed functions are not available\n");
103
104 FreeLibrary(hnetapi32);
105}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void run_apibuf_tests(void)
Definition: apibuf.c:38
#define win_skip
Definition: test.h:160

Variable Documentation

◆ DWORD

Definition at line 34 of file apibuf.c.

◆ LPDWORD

LPVOID *static LPDWORD =NULL

Definition at line 35 of file apibuf.c.