Annotation of embedaddon/php/ext/standard/tests/network/inet_ipv6.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: inet_ntop() & inet_pton() IPv6 tests
! 3: --SKIPIF--
! 4: <?php
! 5: if (!function_exists("inet_ntop")) die("skip no inet_ntop()");
! 6: if (!function_exists("inet_pton")) die("skip no inet_pton()");
! 7:
! 8: $packed = str_repeat(chr(0), 15) . chr(1);
! 9: if (@inet_ntop($packed) === false) {
! 10: die("skip no IPv6 support");
! 11: }
! 12: if (stristr(PHP_OS, "darwin") !== false) die("skip MacOS has broken inet_*() funcs");
! 13: ?>
! 14: --FILE--
! 15: <?php
! 16:
! 17: $a = array(
! 18: '::1',
! 19: '::2',
! 20: '::35',
! 21: '::255',
! 22: '::1024',
! 23: '',
! 24: '2001:0db8:85a3:08d3:1319:8a2e:0370:7344',
! 25: '2001:0db8:1234:0000:0000:0000:0000:0000',
! 26: '2001:0db8:1234:FFFF:FFFF:FFFF:FFFF:FFFF',
! 27: );
! 28:
! 29: foreach ($a as $address) {
! 30: $packed = inet_pton($address);
! 31: var_dump(inet_ntop($packed));
! 32: }
! 33:
! 34: echo "Done\n";
! 35: ?>
! 36: --EXPECTF--
! 37: string(3) "::1"
! 38: string(3) "::2"
! 39: string(4) "::35"
! 40: string(5) "::255"
! 41: string(6) "::1024"
! 42:
! 43: Warning: inet_pton(): Unrecognized address in %s on line %d
! 44:
! 45: Warning: inet_ntop(): Invalid in_addr value in %s on line %d
! 46: bool(false)
! 47: string(36) "2001:db8:85a3:8d3:1319:8a2e:370:7344"
! 48: string(15) "2001:db8:1234::"
! 49: string(38) "2001:db8:1234:ffff:ffff:ffff:ffff:ffff"
! 50: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>