rasapi32: Added some more tests for RasEnumDevicesA, fix Wine not to crash on the...
[wine/multimedia.git] / dlls / rasapi32 / tests / rasapi.c
blobeba492f95e0ace7f3a417010495d961f409c2784
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 cb = 0;
48 RASDEVINFOA rasDevInfo;
49 rasDevInfo.dwSize = sizeof(rasDevInfo);
51 if(!pRasEnumDevicesA) {
52 win_skip("Skipping RasEnumDevicesA tests, function not present\n");
53 return;
56 /* test first parameter */
57 result = pRasEnumDevicesA(NULL, &cb, &cDevices);
58 trace("RasEnumDevicesA: buffersize %d\n", cb);
59 ok(result == ERROR_BUFFER_TOO_SMALL,
60 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
62 cb = sizeof(rasDevInfo);
63 result = pRasEnumDevicesA(NULL, &cb, &cDevices);
64 ok(result == ERROR_BUFFER_TOO_SMALL,
65 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
67 rasDevInfo.dwSize = 0;
68 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
69 todo_wine
70 ok(result == ERROR_INVALID_SIZE,
71 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
73 rasDevInfo.dwSize = sizeof(rasDevInfo) -1;
74 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
75 todo_wine
76 ok(result == ERROR_INVALID_SIZE,
77 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
79 rasDevInfo.dwSize = sizeof(rasDevInfo) +1;
80 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
81 todo_wine
82 ok(result == ERROR_INVALID_SIZE,
83 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
85 /* test second parameter */
86 rasDevInfo.dwSize = sizeof(rasDevInfo);
87 result = pRasEnumDevicesA(&rasDevInfo, NULL, &cDevices);
88 ok(result == ERROR_INVALID_PARAMETER,
89 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
91 cb = 0;
92 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
93 ok(result == ERROR_BUFFER_TOO_SMALL,
94 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
96 cb = sizeof(rasDevInfo) -1;
97 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
98 ok(result == ERROR_BUFFER_TOO_SMALL,
99 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
101 cb = sizeof(rasDevInfo) +1;
102 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
103 todo_wine
104 ok(result == ERROR_BUFFER_TOO_SMALL,
105 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
107 /* test third parameter */
108 cb = sizeof(rasDevInfo);
109 result = pRasEnumDevicesA(&rasDevInfo, &cb, NULL);
110 ok(result == ERROR_INVALID_PARAMETER,
111 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
113 /* test combinations of invalid parameters */
114 result = pRasEnumDevicesA(NULL, NULL, &cDevices);
115 ok(result == ERROR_INVALID_PARAMETER,
116 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
118 result = pRasEnumDevicesA(NULL, &cb, NULL);
119 ok(result == ERROR_INVALID_PARAMETER,
120 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
122 cb = 0;
123 rasDevInfo.dwSize = 0;
124 result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices);
125 todo_wine
126 ok(result == ERROR_INVALID_SIZE,
127 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
130 START_TEST(rasapi)
132 InitFunctionPtrs();
134 test_rasenum();