2 * Unit test suite for rasapi32 functions
4 * Copyright 2008 Austin English
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>
28 static HMODULE hmodule
;
29 static DWORD (WINAPI
*pRasEnumDevicesA
)(LPRASDEVINFOA
, LPDWORD
, LPDWORD
);
31 #define RASAPI32_GET_PROC(func) \
32 p ## func = (void*)GetProcAddress(hmodule, #func); \
34 trace("GetProcAddress(%s) failed\n", #func);
36 static void InitFunctionPtrs(void)
38 hmodule
= LoadLibraryA("rasapi32.dll");
40 RASAPI32_GET_PROC(RasEnumDevicesA
)
43 static void test_rasenum(void)
47 DWORD bufsize
= 0, cb
= 0;
48 LPRASDEVINFOA rasDevInfo
;
50 if(!pRasEnumDevicesA
) {
51 win_skip("Skipping RasEnumDevicesA tests, function not present\n");
55 /* create the return buffer */
56 result
= pRasEnumDevicesA(NULL
, &bufsize
, &cDevices
);
57 trace("RasEnumDevicesA: buffersize %d\n", cb
);
58 ok(result
== ERROR_BUFFER_TOO_SMALL
,
59 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result
);
61 rasDevInfo
= (LPRASDEVINFO
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
62 max(bufsize
,sizeof(RASDEVINFOA
)));
64 win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
68 /* test first parameter */
70 result
= pRasEnumDevicesA(NULL
, &cb
, &cDevices
);
71 ok(result
== ERROR_BUFFER_TOO_SMALL
,
72 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result
);
74 rasDevInfo
[0].dwSize
= 0;
76 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
78 ok(result
== ERROR_INVALID_SIZE
,
79 "Expected ERROR_INVALID_SIZE, got %08d\n", result
);
81 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
) -1;
83 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
85 ok(result
== ERROR_INVALID_SIZE
,
86 "Expected ERROR_INVALID_SIZE, got %08d\n", result
);
88 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
) +1;
90 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
92 ok(result
== ERROR_INVALID_SIZE
,
93 "Expected ERROR_INVALID_SIZE, got %08d\n", result
);
95 /* test second parameter */
96 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
);
97 result
= pRasEnumDevicesA(rasDevInfo
, NULL
, &cDevices
);
98 ok(result
== ERROR_INVALID_PARAMETER
,
99 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result
);
101 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
);
103 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
104 ok(result
== ERROR_BUFFER_TOO_SMALL
,
105 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result
);
107 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
);
109 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
110 ok(result
== ERROR_BUFFER_TOO_SMALL
,
111 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result
);
113 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
);
115 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
116 ok(result
== ERROR_SUCCESS
,
117 "Expected ERROR_SUCCESS, got %08d\n", result
);
119 /* test third parameter */
120 rasDevInfo
[0].dwSize
= sizeof(RASDEVINFOA
);
122 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, NULL
);
123 ok(result
== ERROR_INVALID_PARAMETER
,
124 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result
);
126 /* test combinations of invalid parameters */
127 result
= pRasEnumDevicesA(NULL
, NULL
, &cDevices
);
128 ok(result
== ERROR_INVALID_PARAMETER
,
129 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result
);
131 result
= pRasEnumDevicesA(NULL
, &cb
, NULL
);
132 ok(result
== ERROR_INVALID_PARAMETER
,
133 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result
);
136 rasDevInfo
[0].dwSize
= 0;
137 result
= pRasEnumDevicesA(rasDevInfo
, &cb
, &cDevices
);
139 ok(result
== ERROR_INVALID_SIZE
,
140 "Expected ERROR_INVALID_SIZE, got %08d\n", result
);
142 HeapFree(GetProcessHeap(), 0, rasDevInfo
);