[WS2_32_APITEST] Add some tests for GetAddrInfoW

Test results proves WSAStartup call should precede GetAddrInfoW calls.
This commit is contained in:
Stanislav Motylkov 2019-12-28 23:52:18 +03:00 committed by Victor Perevertkin
parent 1e83f8b5fd
commit fbf4660f46

View 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);
}