]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/test-network-list.c
network-list: Add more networks to test
[people/ms/libloc.git] / src / test-network-list.c
index 8253fc7cf2c17202075369bec4cf5fff66af4fae..6f32ff7ba1e7da4d1b4848f30b08c930b96cf03b 100644 (file)
@@ -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);
        }