Release 1.1.37.
[wine/gsoc-2012-control.git] / dlls / ws2_32 / tests / protocol.c
blob368955b65ba1001ce24263dc4589360acbfb3a62
1 /*
2 * Unit test suite for protocol functions
4 * Copyright 2004 Hans Leidekker
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>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winsock2.h>
27 #include "wine/test.h"
30 static void test_WSAEnumProtocolsA(void)
32 INT ret;
33 DWORD len = 0;
34 WSAPROTOCOL_INFOA info, *buffer;
36 ret = WSAEnumProtocolsA( NULL, NULL, &len );
37 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly: %d\n",
38 WSAGetLastError() );
40 len = 0;
42 ret = WSAEnumProtocolsA( NULL, &info, &len );
43 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly: %d\n",
44 WSAGetLastError() );
46 buffer = HeapAlloc( GetProcessHeap(), 0, len );
48 if (buffer)
50 INT i;
52 ret = WSAEnumProtocolsA( NULL, buffer, &len );
53 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsA() failed unexpectedly: %d\n",
54 WSAGetLastError() );
56 for (i = 0; i < ret; i++)
58 ok( strlen( buffer[i].szProtocol ), "No protocol name found\n" );
61 HeapFree( GetProcessHeap(), 0, buffer );
65 static void test_WSAEnumProtocolsW(void)
67 INT ret;
68 DWORD len = 0;
69 WSAPROTOCOL_INFOW info, *buffer;
71 ret = WSAEnumProtocolsW( NULL, NULL, &len );
72 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly: %d\n",
73 WSAGetLastError() );
75 len = 0;
77 ret = WSAEnumProtocolsW( NULL, &info, &len );
78 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly: %d\n",
79 WSAGetLastError() );
81 buffer = HeapAlloc( GetProcessHeap(), 0, len );
83 if (buffer)
85 INT i;
87 ret = WSAEnumProtocolsW( NULL, buffer, &len );
88 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsW() failed unexpectedly: %d\n",
89 WSAGetLastError() );
91 for (i = 0; i < ret; i++)
93 ok( lstrlenW( buffer[i].szProtocol ), "No protocol name found\n" );
96 HeapFree( GetProcessHeap(), 0, buffer );
100 START_TEST( protocol )
102 WSADATA data;
103 WORD version = MAKEWORD( 2, 2 );
105 if (WSAStartup( version, &data )) return;
107 test_WSAEnumProtocolsA();
108 test_WSAEnumProtocolsW();