From: Michael Tremer Date: Tue, 24 Nov 2020 15:42:54 +0000 (+0000) Subject: test: Add more networks to list to see the algorithm work X-Git-Tag: 0.9.5~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c6983ad52724d395446bdbd24d36b2ce22aecfd;p=people%2Fms%2Flibloc.git test: Add more networks to list to see the algorithm work Signed-off-by: Michael Tremer --- diff --git a/src/test-network-list.c b/src/test-network-list.c index 3061d63..8253fc7 100644 --- a/src/test-network-list.c +++ b/src/test-network-list.c @@ -58,6 +58,20 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } + struct loc_network* subnet3; + err = loc_network_new_from_string(ctx, &subnet3, "2001:db8:c::/48"); + if (err) { + fprintf(stderr, "Could not create the subnet3\n"); + exit(EXIT_FAILURE); + } + + struct loc_network* subnet4; + err = loc_network_new_from_string(ctx, &subnet4, "2001:db8:d::/48"); + if (err) { + fprintf(stderr, "Could not create the subnet4\n"); + exit(EXIT_FAILURE); + } + // Make a list with both subnets struct loc_network_list* subnets; err = loc_network_list_new(ctx, &subnets); @@ -89,8 +103,24 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } + // Add the fourth one next + err = loc_network_list_push(subnets, subnet4); + if (err) { + fprintf(stderr, "Could not add subnet4 to subnets list\n"); + exit(EXIT_FAILURE); + } + + // Add the third one + err = loc_network_list_push(subnets, subnet3); + if (err) { + fprintf(stderr, "Could not add subnet3 to subnets list\n"); + exit(EXIT_FAILURE); + } + + loc_network_list_dump(subnets); + size = loc_network_list_size(subnets); - if (size != 2) { + if (size != 4) { fprintf(stderr, "Network list is reporting an incorrect size: %zu\n", size); exit(EXIT_FAILURE); }