Invert conditions for readability

This commit is contained in:
Richard Hansen 2024-07-10 20:11:02 -04:00
parent 6e7a4fb460
commit 01d2db06c1

View file

@ -41,26 +41,24 @@ subtest "get_ip_from_interface tests" => sub {
subtest "Get default interface and IP for test system (IPv4)" => sub { subtest "Get default interface and IP for test system (IPv4)" => sub {
my $interface = ddclient::get_default_interface(4); my $interface = ddclient::get_default_interface(4);
if ($interface) { return if !$interface;
isnt($interface, "lo", "Check for loopback 'lo'"); isnt($interface, "lo", "Check for loopback 'lo'");
isnt($interface, "lo0", "Check for loopback 'lo0'"); isnt($interface, "lo0", "Check for loopback 'lo0'");
my $ip1 = ddclient::get_ip_from_interface("default", 4); my $ip1 = ddclient::get_ip_from_interface("default", 4);
my $ip2 = ddclient::get_ip_from_interface($interface, 4); my $ip2 = ddclient::get_ip_from_interface($interface, 4);
is($ip1, $ip2, "Check IPv4 from default interface"); is($ip1, $ip2, "Check IPv4 from default interface");
ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)"); ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)");
}
}; };
subtest "Get default interface and IP for test system (IPv6)" => sub { subtest "Get default interface and IP for test system (IPv6)" => sub {
my $interface = ddclient::get_default_interface(6); my $interface = ddclient::get_default_interface(6);
if ($interface) { return if !$interface;
isnt($interface, "lo", "Check for loopback 'lo'"); isnt($interface, "lo", "Check for loopback 'lo'");
isnt($interface, "lo0", "Check for loopback 'lo0'"); isnt($interface, "lo0", "Check for loopback 'lo0'");
my $ip1 = ddclient::get_ip_from_interface("default", 6); my $ip1 = ddclient::get_ip_from_interface("default", 6);
my $ip2 = ddclient::get_ip_from_interface($interface, 6); my $ip2 = ddclient::get_ip_from_interface($interface, 6);
is($ip1, $ip2, "Check IPv6 from default interface"); is($ip1, $ip2, "Check IPv6 from default interface");
ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)"); ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)");
}
}; };
done_testing(); done_testing();