]> git.ipfire.org Git - location/libloc.git/commitdiff
test: Add more networks to list to see the algorithm work
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2020 15:42:54 +0000 (15:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2020 15:42:54 +0000 (15:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/test-network-list.c

index 3061d63e67e6c0b22ab323dbe504c825e6ca7c3d..8253fc7cf2c17202075369bec4cf5fff66af4fae 100644 (file)
@@ -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);
        }