(file) Return to protocol.c CVS log (file) (dir) Up to [RizwankCVS] / wine4 / wine / dlls / winsock / tests

  1 cs130_tom 1.1 /*
  2                * Unit test suite for protocol functions
  3                *
  4                * Copyright 2004 Hans Leidekker
  5                *
  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.
 10                *
 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.
 15                *
 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19                */
 20               
 21               #include <stdarg.h>
 22 cs130_tom 1.1 
 23               #include <windef.h>
 24               #include <winbase.h>
 25               #include <winsock2.h>
 26               
 27               #include "wine/test.h"
 28               
 29               
 30               static void test_WSAEnumProtocolsA()
 31               {
 32                   INT ret;
 33                   DWORD len = 0;
 34                   WSAPROTOCOL_INFOA info, *buffer;
 35               
 36                   ret = WSAEnumProtocolsA( NULL, NULL, &len );
 37                   ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly: %d\n",
 38                       WSAGetLastError() );
 39               
 40                   len = 0;
 41               
 42                   ret = WSAEnumProtocolsA( NULL, &info, &len );
 43 cs130_tom 1.1     ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly: %d\n",
 44                       WSAGetLastError() );
 45               
 46                   buffer = HeapAlloc( GetProcessHeap(), 0, len );
 47               
 48                   if (buffer)
 49                   {
 50                       INT i;
 51               
 52                       ret = WSAEnumProtocolsA( NULL, buffer, &len );
 53                       ok( ret != SOCKET_ERROR, "WSAEnumProtocolsA() failed unexpectedly: %d\n",
 54                           WSAGetLastError() );
 55               
 56                       for (i = 0; i < ret; i++)
 57                       {
 58                           ok( strlen( buffer[i].szProtocol ), "No protocol name found\n" );
 59                       }
 60               
 61                       HeapFree( GetProcessHeap(), 0, buffer );
 62                   }
 63               }
 64 cs130_tom 1.1 
 65               static void test_WSAEnumProtocolsW()
 66               {
 67                   INT ret;
 68                   DWORD len = 0;
 69                   WSAPROTOCOL_INFOW info, *buffer;
 70               
 71                   ret = WSAEnumProtocolsW( NULL, NULL, &len );
 72                   ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly: %d\n",
 73                       WSAGetLastError() );
 74               
 75                   len = 0;
 76               
 77                   ret = WSAEnumProtocolsW( NULL, &info, &len );
 78                   ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly: %d\n",
 79                       WSAGetLastError() );
 80               
 81                   buffer = HeapAlloc( GetProcessHeap(), 0, len );
 82               
 83                   if (buffer)
 84                   {
 85 cs130_tom 1.1         INT i;
 86               
 87                       ret = WSAEnumProtocolsW( NULL, buffer, &len );
 88                       ok( ret != SOCKET_ERROR, "WSAEnumProtocolsW() failed unexpectedly: %d\n",
 89                           WSAGetLastError() );
 90               
 91                       for (i = 0; i < ret; i++)
 92                       {
 93                           ok( lstrlenW( buffer[i].szProtocol ), "No protocol name found\n" );
 94                       }
 95               
 96                       HeapFree( GetProcessHeap(), 0, buffer );
 97                   }
 98               }
 99               
100               START_TEST( protocol )
101               {
102                   WSADATA data;
103                   WORD version = MAKEWORD( 2, 2 );
104                
105                   if (WSAStartup( version, &data )) return;
106 cs130_tom 1.1 
107                   test_WSAEnumProtocolsA();
108                   test_WSAEnumProtocolsW();
109               }

Rizwan Kassim
Powered by
ViewCVS 0.9.2