diff options
author | sfan5 <sfan5@live.de> | 2021-12-29 23:01:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-29 23:01:26 +0100 |
commit | 0ea8df4d64959a7c7ec4e55b4895d6b16dad3000 (patch) | |
tree | 3f1e0cf533142974d2d294f890396992bfdcbe02 /src/unittest | |
parent | 05573d6d8d9e5a756ab1b03b159b127144f8e775 (diff) | |
download | minetest-0ea8df4d64959a7c7ec4e55b4895d6b16dad3000.tar.gz minetest-0ea8df4d64959a7c7ec4e55b4895d6b16dad3000.tar.bz2 minetest-0ea8df4d64959a7c7ec4e55b4895d6b16dad3000.zip |
Socket-related cleanups
Improve error handling on Windows and reduce the size of the `Address` class
Diffstat (limited to 'src/unittest')
-rw-r--r-- | src/unittest/test_socket.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
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); } } |