8 require_ok( 'includes/IP.php' );
10 # some of this test data was taken from Data::Validate::IP
16 foreach ( range( 0, 255 ) as $i ) {
17 $a = sprintf( "%03d", $i );
18 $b = sprintf( "%02d", $i );
19 $c = sprintf( "%01d", $i );
20 foreach ( array_unique( array( $a, $b, $c ) ) as $f ) {
22 ok( IP
::isValid( $ip ), "$ip is a valid IPv4 address" );
26 # A bit excessive perhaps? meh..
27 foreach ( range( 256, 999 ) as $i ) {
28 $a = sprintf( "%03d", $i );
29 $b = sprintf( "%02d", $i );
30 $c = sprintf( "%01d", $i );
31 foreach ( array_unique( array( $a, $b, $c ) ) as $f ) {
33 ok( ! IP
::isValid( $ip ), "$ip is not a valid IPv4 address" );
38 'www.xn--var-xla.net',
46 foreach ( $invalid as $i ) {
47 ok( ! IP
::isValid( $i ), "$i is an invalid IPv4 address" );
54 $private = array( '10.0.0.1', '172.16.0.1', '192.168.0.1' );
56 foreach ( $private as $p ) {
57 ok( ! IP
::isPublic( $p ), "$p is not a public IP address" );
60 /* vim: set filetype=php: */