Partial merge of condrv_restructure branch r65657.
[reactos.git] / rostests / apitests / ws2_32 / nostartup.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for WSAStartup
5 * PROGRAMMER: Sylvain Petreolle <sylvain.petreolle@reactos.org>
6 */
7
8 #include <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #define _INC_WINDOWS
12 #define COM_NO_WINDOWS_H
13
14 #include <windef.h>
15 #include <winsock2.h>
16 #include <ndk/rtlfuncs.h>
17 #include <ndk/mmfuncs.h>
18
19 // This test depends on WSAStartup not having been called
20 START_TEST(nostartup)
21 {
22 int Error = 0;
23 ok(WSASocketA(0, 0, 0, NULL, 0, 0) == INVALID_SOCKET, "WSASocketA should have failed\n");
24
25 WSASetLastError(0xdeadbeef);
26 getservbyname(NULL, NULL);
27 Error = WSAGetLastError();
28 ok_dec(Error, WSANOTINITIALISED);
29
30 WSASetLastError(0xdeadbeef);
31 getservbyport(0, NULL);
32 Error = WSAGetLastError();
33 ok_dec(Error, WSANOTINITIALISED);
34
35 WSASetLastError(0xdeadbeef);
36 gethostbyname(NULL);
37 Error = WSAGetLastError();
38 ok_dec(Error, WSANOTINITIALISED);
39
40 ok_dec(inet_addr("127.0.0.1"), 0x100007f);
41 }