From d3a5f691731e176d2d869d37bd81cc29d44620cd Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 26 Nov 2020 10:14:08 +0000 Subject: [PATCH] network-list: Add more networks to test Signed-off-by: Michael Tremer --- src/test-network-list.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/test-network-list.c b/src/test-network-list.c index 8253fc7..6f32ff7 100644 --- a/src/test-network-list.c +++ b/src/test-network-list.c @@ -72,6 +72,20 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } + struct loc_network* subnet5; + err = loc_network_new_from_string(ctx, &subnet5, "2001:db8:e::/48"); + if (err) { + fprintf(stderr, "Could not create the subnet5\n"); + exit(EXIT_FAILURE); + } + + struct loc_network* subnet6; + err = loc_network_new_from_string(ctx, &subnet6, "2001:db8:1::/48"); + if (err) { + fprintf(stderr, "Could not create the subnet6\n"); + exit(EXIT_FAILURE); + } + // Make a list with both subnets struct loc_network_list* subnets; err = loc_network_list_new(ctx, &subnets); @@ -117,10 +131,23 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } + // Add more subnets + err = loc_network_list_push(subnets, subnet5); + if (err) { + fprintf(stderr, "Could not add subnet5 to subnets list\n"); + exit(EXIT_FAILURE); + } + + err = loc_network_list_push(subnets, subnet6); + if (err) { + fprintf(stderr, "Could not add subnet6 to subnets list\n"); + exit(EXIT_FAILURE); + } + loc_network_list_dump(subnets); size = loc_network_list_size(subnets); - if (size != 4) { + if (size != 6) { fprintf(stderr, "Network list is reporting an incorrect size: %zu\n", size); exit(EXIT_FAILURE); } -- 2.39.2