ipaddresses::netmask2cidr : manage the calculation of the wildcard IP

ipaddresses::netmask2cidr : catch invalid IP mask and return false


git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5987 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2020-05-11 19:39:20 +00:00
parent e1f1ddaa24
commit 068b1e3ec3
2 changed files with 51 additions and 6 deletions

View File

@@ -363,6 +363,32 @@ class ipaddressesTest extends PHPUnit_Framework_TestCase
$res = $i->netmask2cidr ("63.0.0.0");
$this->assertSame (6, $res);
}
public function test_netmask2cidr8 ()
{
$i = new ipaddresses ();
$res = $i->netmask2cidr ("155.0.0.0");
$this->assertSame (false, $res);
}
public function test_netmask2cidrWildcard_1 ()
{
$i = new ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.0", false);
$this->assertSame (false, $res);
}
public function test_netmask2cidrWildcard_2 ()
{
$i = new ipaddresses ();
$res = $i->netmask2cidr ("0.0.0.0", false);
$this->assertSame (32, $res);
}
public function test_netmask2cidrWildcard_3 ()
{
$i = new ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.255", false);
$this->assertSame (0, $res);
}
public function test_ipInNetwork1 ()
{