summaryrefslogtreecommitdiff
path: root/auto_tests/network_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/network_test.c')
-rw-r--r--auto_tests/network_test.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index 31521cbc..200c04db 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -38,7 +38,8 @@ START_TEST(test_addr_resolv_localhost)
38 38
39 char ip_str[IP_NTOA_LEN]; 39 char ip_str[IP_NTOA_LEN];
40 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); 40 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family);
41 ck_assert_msg(ip.ip4.uint32 == net_htonl(0x7F000001), "Expected 127.0.0.1, got %s.", 41 const uint32_t loopback = net_htonl(IP4_LOOPBACK.uint32);
42 ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.",
42 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 43 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
43 44
44 ip_init(&ip, 1); // ipv6enabled = 1 45 ip_init(&ip, 1); // ipv6enabled = 1
@@ -52,7 +53,7 @@ START_TEST(test_addr_resolv_localhost)
52 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 53 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
53 54
54 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); 55 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family);
55 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", 56 ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.",
56 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 57 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
57 58
58 if (localhost_split) { 59 if (localhost_split) {
@@ -68,11 +69,11 @@ START_TEST(test_addr_resolv_localhost)
68 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 69 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
69 70
70 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); 71 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family);
71 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", 72 ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.",
72 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 73 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
73 74
74 ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); 75 ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family);
75 ck_assert_msg(extra.ip4.uint32 == net_htonl(0x7F000001), "Expected 127.0.0.1, got %s.", 76 ck_assert_msg(extra.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.",
76 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 77 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
77} 78}
78END_TEST 79END_TEST
@@ -126,7 +127,7 @@ START_TEST(test_ip_equal)
126 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " 127 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): "
127 "expected result != 0, got 0."); 128 "expected result != 0, got 0.");
128 129
129 memcpy(&ip2.ip6, &in6addr_loopback, sizeof(IP6)); 130 memcpy(&ip2.ip6, &IP6_LOOPBACK, sizeof(IP6));
130 res = ip_equal(&ip1, &ip2); 131 res = ip_equal(&ip1, &ip2);
131 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); 132 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res);
132 133