1--TEST--
2inet_ntop() & inet_pton() IPv6 tests
3--SKIPIF--
4<?php
5if (!function_exists("inet_ntop")) die("skip no inet_ntop()");
6if (!function_exists("inet_pton")) die("skip no inet_pton()");
7
8$packed = str_repeat(chr(0), 15) . chr(1);
9if (@inet_ntop($packed) === false) {
10    die("skip no IPv6 support");
11}
12if (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
29foreach ($a as $address) {
30    $packed = inet_pton($address);
31    var_dump(inet_ntop($packed));
32}
33
34echo "Done\n";
35?>
36--EXPECT--
37string(3) "::1"
38string(3) "::2"
39string(4) "::35"
40string(5) "::255"
41string(6) "::1024"
42bool(false)
43string(36) "2001:db8:85a3:8d3:1319:8a2e:370:7344"
44string(15) "2001:db8:1234::"
45string(38) "2001:db8:1234:ffff:ffff:ffff:ffff:ffff"
46Done
47