// Create a network
struct loc_network* network1;
- err = loc_network_new_from_string(ctx, &network1, "2001:db8::/32");
+ err = loc_network_new_from_string(ctx, &network1, "2001:db8::1/32");
if (err) {
fprintf(stderr, "Could not create the network\n");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
+ // Check if the first and last addresses are correct
+ char* string = loc_network_format_first_address(network1);
+ if (!string) {
+ fprintf(stderr, "Did get NULL instead of a string for the first address\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (strcmp(string, "2001:db8::") != 0) {
+ fprintf(stderr, "Got an incorrect first address: %s\n", string);
+ exit(EXIT_FAILURE);
+ }
+
+ string = loc_network_format_last_address(network1);
+ if (!string) {
+ fprintf(stderr, "Did get NULL instead of a string for the last address\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (strcmp(string, "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff") != 0) {
+ fprintf(stderr, "Got an incorrect last address: %s\n", string);
+ exit(EXIT_FAILURE);
+ }
+
struct loc_network* network2;
err = loc_network_new_from_string(ctx, &network2, "2001:db8:ffff::/48");
if (err) {