Zebediah Figura : ws2_32/tests: Add tests for inet_addr().

Alexandre Julliard julliard at winehq.org
Tue Aug 3 16:52:22 CDT 2021


Module: wine
Branch: master
Commit: b159f6e25667652afe278a5df7504cafdc1f26e1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b159f6e25667652afe278a5df7504cafdc1f26e1

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon Aug  2 19:37:41 2021 -0500

ws2_32/tests: Add tests for inet_addr().

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/protocol.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index e14f5c60762..0a2e42721af 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -942,6 +942,11 @@ static void test_inet_pton(void)
     ok(ret == -1, "got %d\n", ret);
     ok(WSAGetLastError() == WSAEAFNOSUPPORT, "got error %u\n", WSAGetLastError());
 
+    WSASetLastError(0xdeadbeef);
+    ret = inet_addr(NULL);
+    ok(ret == INADDR_NONE, "got %#x\n", ret);
+    todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
+
     for (i = 0; i < ARRAY_SIZE(ipv4_tests); ++i)
     {
         WCHAR inputW[32];
@@ -963,6 +968,13 @@ static void test_inet_pton(void)
         ok(WSAGetLastError() == (ret ? 0xdeadbeef : WSAEINVAL), "%s: got error %u\n",
                 debugstr_a(ipv4_tests[i].input), WSAGetLastError());
         ok(addr == ipv4_tests[i].addr, "%s: got addr %#08x\n", debugstr_a(ipv4_tests[i].input), addr);
+
+        WSASetLastError(0xdeadbeef);
+        addr = inet_addr(ipv4_tests[i].input);
+        ok(addr == ipv4_tests[i].ret ? ipv4_tests[i].addr : INADDR_NONE,
+                "%s: got addr %#08x\n", debugstr_a(ipv4_tests[i].input), addr);
+        ok(WSAGetLastError() == 0xdeadbeef, "%s: got error %u\n",
+                debugstr_a(ipv4_tests[i].input), WSAGetLastError());
     }
 
     for (i = 0; i < ARRAY_SIZE(ipv6_tests); ++i)
@@ -1505,14 +1517,6 @@ static void test_WSAStringToAddress(void)
     }
 }
 
-static void test_inet_addr(void)
-{
-    u_long addr;
-
-    addr = inet_addr(NULL);
-    ok(addr == INADDR_NONE, "inet_addr succeeded unexpectedly\n");
-}
-
 /* Tests used in both getaddrinfo and GetAddrInfoW */
 static const struct addr_hint_tests
 {
@@ -2818,7 +2822,6 @@ START_TEST( protocol )
     test_addr_to_print();
     test_WSAAddressToString();
     test_WSAStringToAddress();
-    test_inet_addr();
 
     test_GetAddrInfoW();
     test_GetAddrInfoExW();




More information about the wine-cvs mailing list