]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-net - Update tests for net_addr2ip() and net_ip2addr()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 4 Apr 2022 09:33:13 +0000 (12:33 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 14 Apr 2022 11:10:37 +0000 (11:10 +0000)
src/lib/test-net.c

index fb19d5bf0d8f1970d65cdc2ff4f486a3cd6e88bc..7e116086638a238f8060ef158ef5cde82d7304e8 100644 (file)
@@ -31,7 +31,8 @@ static void test_net_is_in_network(void)
                { "123e::ffff", "123e::0", 15, TRUE },
                { "::ffff:1.2.3.4", "1.2.3.4", 32, TRUE },
                { "::ffff:1.2.3.4", "1.2.3.3", 32, FALSE },
-               { "::ffff:1.2.3.4", "::ffff:1.2.3.4", 0, FALSE }
+               { "::ffff:1.2.3.4", "::ffff:1.2.3.4", 0, FALSE },
+               { "fe80::1%lo", "fe80::", 8, TRUE },
        };
        struct ip_addr ip, net_ip;
        unsigned int i;
@@ -84,6 +85,10 @@ static void test_net_ip2addr(void)
        ip.family = 123;
        test_assert(net_addr2ip("abc", &ip) < 0 &&
                    ip.family == 123);
+       test_assert(net_addr2ip("fe80::1", &ip) == 0);
+       test_assert_strcmp(net_ip2addr(&ip), "fe80::1");
+       test_assert(net_addr2ip("fe80::1%lo", &ip) == 0);
+       test_assert_strcmp(net_ip2addr(&ip), "fe80::1%lo");
        test_end();
 }