push e263afdf8dbf9f9408e8594e045d25c4af1d55cd
[wine/hacks.git] / dlls / rasapi32 / tests / rasapi.c
blob4130392b3e8b37f7f92745b22c8bba54f75c08dd
1 /*
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
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <wine/test.h>
24 #include <windef.h>
25 #include <winbase.h>
26 #include "ras.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); \
33 if(!p ## 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)
45 DWORD result;
46 DWORD cDevices = 0;
47 DWORD bufsize = 0, cb = 0;
48 LPRASDEVINFOA rasDevInfo;
50 if(!pRasEnumDevicesA) {
51 win_skip("Skipping RasEnumDevicesA tests, function not present\n");
52 return;
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)));
63 if(!rasDevInfo) {
64 win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
65 return;
68 /* test first parameter */
69 cb = bufsize;
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;
75 cb = bufsize;
76 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
77 todo_wine
78 ok(result == ERROR_INVALID_SIZE,
79 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
81 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
82 cb = bufsize;
83 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
84 todo_wine
85 ok(result == ERROR_INVALID_SIZE,
86 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
88 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
89 cb = bufsize;
90 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
91 todo_wine
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);
102 cb = 0;
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);
108 cb = bufsize -1;
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);
114 cb = bufsize +1;
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);
121 cb = bufsize;
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);
135 cb = 0;
136 rasDevInfo[0].dwSize = 0;
137 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
138 todo_wine
139 ok(result == ERROR_INVALID_SIZE,
140 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
142 HeapFree(GetProcessHeap(), 0, rasDevInfo);
145 START_TEST(rasapi)
147 InitFunctionPtrs();
149 test_rasenum();