[WS2_32_APITEST] Add some tests for GetAddrInfoW
authorStanislav Motylkov <x86corez@gmail.com>
Sat, 28 Dec 2019 20:52:18 +0000 (23:52 +0300)
committerVictor Perevertkin <victor@perevertkin.ru>
Wed, 1 Jan 2020 16:53:40 +0000 (18:53 +0200)
Test results proves WSAStartup call should precede GetAddrInfoW calls.

modules/rostests/apitests/ws2_32/getaddrinfo.c

index 369c5b3..068881a 100644 (file)
@@ -199,7 +199,9 @@ START_TEST(getaddrinfo)
     WSADATA WsaData;
     int Error;
     PADDRINFOA AddrInfo;
+    PADDRINFOW AddrInfoW;
     ADDRINFOA Hints;
+    ADDRINFOW HintsW;
     CHAR LocalHostName[128];
     struct hostent *Hostent;
 
@@ -218,6 +220,9 @@ START_TEST(getaddrinfo)
     Error = getaddrinfo("127.0.0.1", "80", NULL, &AddrInfo);
     ok_dec(Error, WSANOTINITIALISED);
 
+    Error = GetAddrInfoW(L"127.0.0.1", L"80", NULL, &AddrInfoW);
+    ok_dec(Error, WSANOTINITIALISED);
+
     Error = WSAStartup(MAKEWORD(2, 2), &WsaData);
     ok_dec(Error, 0);
 
@@ -239,7 +244,7 @@ START_TEST(getaddrinfo)
        "Could not determine local address. Following test results may be wrong.\n");
 
     ZeroMemory(&Hints, sizeof(Hints));
-    /* parameter tests */
+    /* parameter tests for getaddrinfo */
     StartSeh() getaddrinfo(NULL, NULL, NULL, NULL); EndSeh(STATUS_ACCESS_VIOLATION);
     StartSeh() getaddrinfo("", "", &Hints, NULL);   EndSeh(STATUS_ACCESS_VIOLATION);
     StartSeh()
@@ -250,6 +255,17 @@ START_TEST(getaddrinfo)
         ok_ptr(AddrInfo, NULL);
     EndSeh(STATUS_SUCCESS);
 
+    /* parameter tests for GetAddrInfoW */
+    StartSeh() GetAddrInfoW(NULL, NULL, NULL, NULL);  EndSeh(STATUS_ACCESS_VIOLATION);
+    StartSeh() GetAddrInfoW(L"", L"", &HintsW, NULL); EndSeh(STATUS_ACCESS_VIOLATION);
+    StartSeh()
+        AddrInfo = InvalidPointer;
+        Error = GetAddrInfoW(NULL, NULL, NULL, &AddrInfoW);
+        ok_dec(Error, WSAHOST_NOT_FOUND);
+        ok_dec(WSAGetLastError(), WSAHOST_NOT_FOUND);
+        ok_ptr(AddrInfo, InvalidPointer); /* differs from getaddrinfo */
+    EndSeh(STATUS_SUCCESS);
+
     TestNodeName();
     TestServiceName();
     /* TODO: test passing both node name and service name */
@@ -262,4 +278,7 @@ START_TEST(getaddrinfo)
     /* not initialized anymore */
     Error = getaddrinfo("127.0.0.1", "80", NULL, &AddrInfo);
     ok_dec(Error, WSANOTINITIALISED);
+
+    Error = GetAddrInfoW(L"127.0.0.1", L"80", NULL, &AddrInfoW);
+    ok_dec(Error, WSANOTINITIALISED);
 }