From 0ea8df4d64959a7c7ec4e55b4895d6b16dad3000 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 29 Dec 2021 23:01:26 +0100 Subject: Socket-related cleanups Improve error handling on Windows and reduce the size of the `Address` class --- src/unittest/test_socket.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/unittest/test_socket.cpp') diff --git a/src/unittest/test_socket.cpp b/src/unittest/test_socket.cpp index 6d5cf334d..620021b59 100644 --- a/src/unittest/test_socket.cpp +++ b/src/unittest/test_socket.cpp @@ -97,11 +97,11 @@ void TestSocket::testIPv4Socket() UASSERT(strncmp(sendbuffer, rcvbuffer, sizeof(sendbuffer)) == 0); if (address != Address(0, 0, 0, 0, port)) { - UASSERT(sender.getAddress().sin_addr.s_addr == - address.getAddress().sin_addr.s_addr); + UASSERT(sender.getAddress().s_addr == + address.getAddress().s_addr); } else { - UASSERT(sender.getAddress().sin_addr.s_addr == - Address(127, 0, 0, 1, 0).getAddress().sin_addr.s_addr); + UASSERT(sender.getAddress().s_addr == + Address(127, 0, 0, 1, 0).getAddress().s_addr); } } @@ -128,7 +128,7 @@ void TestSocket::testIPv6Socket() socket6.Bind(address6); - try { + { socket6.Send(Address(&bytes, port), sendbuffer, sizeof(sendbuffer)); sleep_ms(50); @@ -142,10 +142,8 @@ void TestSocket::testIPv6Socket() } //FIXME: This fails on some systems UASSERT(strncmp(sendbuffer, rcvbuffer, sizeof(sendbuffer)) == 0); - UASSERT(memcmp(sender.getAddress6().sin6_addr.s6_addr, - Address(&bytes, 0).getAddress6().sin6_addr.s6_addr, 16) == 0); - } catch (SendFailedException &e) { - errorstream << "IPv6 support enabled but not available!" - << std::endl; + + UASSERT(memcmp(sender.getAddress6().s6_addr, + Address(&bytes, 0).getAddress6().s6_addr, 16) == 0); } } -- cgit v1.2.3