1--TEST--
2inet_ntop() & inet_pton() IPv6 tests
3--SKIPIF--
4<?php
5
6$packed = str_repeat(chr(0), 15) . chr(1);
7if (@inet_ntop($packed) === false) {
8    die("skip no IPv6 support");
9}
10if (stristr(PHP_OS, "darwin") !== false) die("skip MacOS has broken inet_*() funcs");
11?>
12--FILE--
13<?php
14
15$a = array(
16    '::1',
17    '::2',
18    '::35',
19    '::255',
20    '::1024',
21    '',
22    '2001:0db8:85a3:08d3:1319:8a2e:0370:7344',
23    '2001:0db8:1234:0000:0000:0000:0000:0000',
24    '2001:0db8:1234:FFFF:FFFF:FFFF:FFFF:FFFF',
25);
26
27foreach ($a as $address) {
28    $packed = inet_pton($address);
29    var_dump(inet_ntop($packed));
30}
31
32echo "Done\n";
33?>
34--EXPECT--
35string(3) "::1"
36string(3) "::2"
37string(4) "::35"
38string(5) "::255"
39string(6) "::1024"
40bool(false)
41string(36) "2001:db8:85a3:8d3:1319:8a2e:370:7344"
42string(15) "2001:db8:1234::"
43string(38) "2001:db8:1234:ffff:ffff:ffff:ffff:ffff"
44Done
45