Mercurial > dovecot > core-2.2
changeset 18501:334bb95f27d4
lib: Renamed test-network to test-net
Since network.c had been renamed to net.c some time ago.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 29 Apr 2015 17:36:44 +0200 |
parents | 4903ab967807 |
children | 009648acd7fb |
files | src/lib/Makefile.am src/lib/test-lib.c src/lib/test-lib.h src/lib/test-net.c src/lib/test-network.c |
diffstat | 5 files changed, 56 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/Makefile.am Wed Apr 29 17:35:18 2015 +0200 +++ b/src/lib/Makefile.am Wed Apr 29 17:36:44 2015 +0200 @@ -310,7 +310,7 @@ test-json-tree.c \ test-llist.c \ test-mempool-alloconly.c \ - test-network.c \ + test-net.c \ test-numpack.c \ test-ostream-file.c \ test-primes.c \
--- a/src/lib/test-lib.c Wed Apr 29 17:35:18 2015 +0200 +++ b/src/lib/test-lib.c Wed Apr 29 17:36:44 2015 +0200 @@ -32,7 +32,7 @@ test_json_tree, test_llist, test_mempool_alloconly, - test_network, + test_net, test_numpack, test_ostream_file, test_primes,
--- a/src/lib/test-lib.h Wed Apr 29 17:35:18 2015 +0200 +++ b/src/lib/test-lib.h Wed Apr 29 17:36:44 2015 +0200 @@ -34,7 +34,7 @@ void test_llist(void); void test_mempool_alloconly(void); enum fatal_test_state fatal_mempool(int); -void test_network(void); +void test_net(void); void test_numpack(void); void test_ostream_file(void); void test_primes(void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/test-net.c Wed Apr 29 17:36:44 2015 +0200 @@ -0,0 +1,53 @@ +/* Copyright (c) 2007-2015 Dovecot authors, see the included COPYING file */ + +#include "test-lib.h" +#include "net.h" + +struct test_net_is_in_network_input { + const char *ip; + const char *net; + unsigned int bits; + bool ret; +}; + +static void test_net_is_in_network(void) +{ + static struct test_net_is_in_network_input input[] = { + { "1.2.3.4", "1.2.3.4", 32, TRUE }, + { "1.2.3.4", "1.2.3.3", 32, FALSE }, + { "1.2.3.4", "1.2.3.5", 32, FALSE }, + { "1.2.3.4", "1.2.2.4", 32, FALSE }, + { "1.2.3.4", "1.1.3.4", 32, FALSE }, + { "1.2.3.4", "0.2.3.4", 32, FALSE }, + { "1.2.3.253", "1.2.3.254", 31, FALSE }, + { "1.2.3.254", "1.2.3.254", 31, TRUE }, + { "1.2.3.255", "1.2.3.254", 31, TRUE }, + { "1.2.3.255", "1.2.3.0", 24, TRUE }, + { "1.2.255.255", "1.2.254.0", 23, TRUE }, + { "255.255.255.255", "128.0.0.0", 1, TRUE }, + { "255.255.255.255", "127.0.0.0", 1, FALSE } +#ifdef HAVE_IPV6 + , + { "1234:5678::abcf", "1234:5678::abce", 127, TRUE }, + { "1234:5678::abcd", "1234:5678::abce", 127, FALSE }, + { "123e::ffff", "123e::0", 15, TRUE }, + { "123d::ffff", "123e::0", 15, FALSE } +#endif + }; + struct ip_addr ip, net_ip; + unsigned int i; + bool success; + + for (i = 0; i < N_ELEMENTS(input); i++) { + test_assert(net_addr2ip(input[i].ip, &ip) == 0); + test_assert(net_addr2ip(input[i].net, &net_ip) == 0); + success = net_is_in_network(&ip, &net_ip, input[i].bits) == + input[i].ret; + test_out(t_strdup_printf("net_is_in_network(%u)", i), success); + } +} + +void test_net(void) +{ + test_net_is_in_network(); +}
--- a/src/lib/test-network.c Wed Apr 29 17:35:18 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* Copyright (c) 2007-2015 Dovecot authors, see the included COPYING file */ - -#include "test-lib.h" -#include "net.h" - -struct test_net_is_in_network_input { - const char *ip; - const char *net; - unsigned int bits; - bool ret; -}; - -static void test_net_is_in_network(void) -{ - static struct test_net_is_in_network_input input[] = { - { "1.2.3.4", "1.2.3.4", 32, TRUE }, - { "1.2.3.4", "1.2.3.3", 32, FALSE }, - { "1.2.3.4", "1.2.3.5", 32, FALSE }, - { "1.2.3.4", "1.2.2.4", 32, FALSE }, - { "1.2.3.4", "1.1.3.4", 32, FALSE }, - { "1.2.3.4", "0.2.3.4", 32, FALSE }, - { "1.2.3.253", "1.2.3.254", 31, FALSE }, - { "1.2.3.254", "1.2.3.254", 31, TRUE }, - { "1.2.3.255", "1.2.3.254", 31, TRUE }, - { "1.2.3.255", "1.2.3.0", 24, TRUE }, - { "1.2.255.255", "1.2.254.0", 23, TRUE }, - { "255.255.255.255", "128.0.0.0", 1, TRUE }, - { "255.255.255.255", "127.0.0.0", 1, FALSE } -#ifdef HAVE_IPV6 - , - { "1234:5678::abcf", "1234:5678::abce", 127, TRUE }, - { "1234:5678::abcd", "1234:5678::abce", 127, FALSE }, - { "123e::ffff", "123e::0", 15, TRUE }, - { "123d::ffff", "123e::0", 15, FALSE } -#endif - }; - struct ip_addr ip, net_ip; - unsigned int i; - bool success; - - for (i = 0; i < N_ELEMENTS(input); i++) { - test_assert(net_addr2ip(input[i].ip, &ip) == 0); - test_assert(net_addr2ip(input[i].net, &net_ip) == 0); - success = net_is_in_network(&ip, &net_ip, input[i].bits) == - input[i].ret; - test_out(t_strdup_printf("net_is_in_network(%u)", i), success); - } -} - -void test_network(void) -{ - test_net_is_in_network(); -}