Annotation of embedaddon/php/ext/standard/tests/network/ip.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ip2long() & long2ip() tests
! 3: --SKIPIF--
! 4: <?php
! 5: if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
! 6: ?>
! 7: --FILE--
! 8: <?php
! 9:
! 10: $array = array(
! 11: "127.0.0.1",
! 12: "10.0.0.1",
! 13: "255.255.255.255",
! 14: "255.255.255.0",
! 15: "0.0.0.0",
! 16: "66.163.161.116",
! 17: );
! 18:
! 19: foreach ($array as $ip) {
! 20: var_dump($long = ip2long($ip));
! 21: var_dump(long2ip($long));
! 22: }
! 23:
! 24: var_dump(ip2long());
! 25: var_dump(ip2long(""));
! 26: var_dump(ip2long("777.777.777.777"));
! 27: var_dump(ip2long("111.111.111.111"));
! 28: var_dump(ip2long(array()));
! 29:
! 30: var_dump(long2ip());
! 31: var_dump(long2ip(-110000));
! 32: var_dump(long2ip(""));
! 33: var_dump(long2ip(array()));
! 34:
! 35: echo "Done\n";
! 36: ?>
! 37: --EXPECTF--
! 38: int(2130706433)
! 39: string(9) "127.0.0.1"
! 40: int(167772161)
! 41: string(8) "10.0.0.1"
! 42: int(-1)
! 43: string(15) "255.255.255.255"
! 44: int(-256)
! 45: string(13) "255.255.255.0"
! 46: int(0)
! 47: string(7) "0.0.0.0"
! 48: int(1118019956)
! 49: string(14) "66.163.161.116"
! 50:
! 51: Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
! 52: NULL
! 53: bool(false)
! 54: bool(false)
! 55: int(1869573999)
! 56:
! 57: Warning: ip2long() expects parameter 1 to be string, array given in %s on line %d
! 58: NULL
! 59:
! 60: Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
! 61: NULL
! 62: string(13) "255.254.82.80"
! 63: string(7) "0.0.0.0"
! 64:
! 65: Warning: long2ip() expects parameter 1 to be string, array given in %s on line %d
! 66: NULL
! 67: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>