]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/test-network-list.c
address: Fix bit length calculation
[people/ms/libloc.git] / src / test-network-list.c
index 8253fc7cf2c17202075369bec4cf5fff66af4fae..70a6b89bdee916c529ea01f245fe0446b1ddb4cb 100644 (file)
@@ -21,9 +21,9 @@
 #include <string.h>
 #include <syslog.h>
 
-#include <loc/libloc.h>
-#include <loc/network.h>
-#include <loc/network-list.h>
+#include <libloc/libloc.h>
+#include <libloc/network.h>
+#include <libloc/network-list.h>
 
 int main(int argc, char** argv) {
        int err;
@@ -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);
        }