[IPHLPAPI_APITEST] Add some tests for GetNetworkParams. By Peter Hater. ROSTESTS-244
[reactos.git] / rostests / apitests / iphlpapi / icmp.c
1 /*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Tests for ICMP functions
5 * PROGRAMMERS: Tim Crawford
6 */
7
8 #include <apitest.h>
9 #include <ws2tcpip.h>
10 #include <iphlpapi.h>
11 #include <icmpapi.h>
12
13 static
14 void
15 test_IcmpCreateFile(void)
16 {
17 HANDLE hIcmp;
18
19 SetLastError(0xDEADBEEF);
20 hIcmp = IcmpCreateFile();
21 ok(hIcmp != INVALID_HANDLE_VALUE, "IcmpCreateFile failed unexpectedly: %lu\n", GetLastError());
22
23 if (hIcmp != INVALID_HANDLE_VALUE)
24 IcmpCloseHandle(hIcmp);
25 }
26
27 static
28 void
29 test_Icmp6CreateFile(void)
30 {
31 HANDLE hIcmp;
32
33 SetLastError(0xDEADBEEF);
34 hIcmp = Icmp6CreateFile();
35
36 if (GetLastError() == ERROR_FILE_NOT_FOUND)
37 {
38 /* On Windows Server 2003, the IPv6 protocol must be installed. */
39 skip("IPv6 is not available.\n");
40 return;
41 }
42
43 ok(hIcmp != INVALID_HANDLE_VALUE, "Icmp6CreateFile failed unexpectedly: %lu\n", GetLastError());
44
45 if (hIcmp != INVALID_HANDLE_VALUE)
46 IcmpCloseHandle(hIcmp);
47 }
48
49 static
50 void
51 test_IcmpCloseHandle(void)
52 {
53 HANDLE hIcmp;
54 BOOL bRet;
55
56 SetLastError(0xDEADBEEF);
57 hIcmp = IcmpCreateFile();
58 if (hIcmp != INVALID_HANDLE_VALUE)
59 {
60 bRet = IcmpCloseHandle(hIcmp);
61 ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
62 }
63
64 SetLastError(0xDEADBEEF);
65 hIcmp = Icmp6CreateFile();
66 if (hIcmp != INVALID_HANDLE_VALUE)
67 {
68 bRet = IcmpCloseHandle(hIcmp);
69 ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
70 }
71
72 hIcmp = INVALID_HANDLE_VALUE;
73 SetLastError(0xDEADBEEF);
74 bRet = IcmpCloseHandle(hIcmp);
75 ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
76 ok_err(ERROR_INVALID_HANDLE);
77
78 hIcmp = NULL;
79 SetLastError(0xDEADBEEF);
80 bRet = IcmpCloseHandle(hIcmp);
81 ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
82 ok_err(ERROR_INVALID_HANDLE);
83 }
84
85 START_TEST(icmp)
86 {
87 test_IcmpCreateFile();
88 test_Icmp6CreateFile();
89 test_IcmpCloseHandle();
90 }