Annotation of embedaddon/php/ext/standard/tests/network/inet.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: inet_ntop() & inet_pton() 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: --FILE--
                      9: <?php
                     10: 
                     11: $packed = chr(127) . chr(0) . chr(0) . chr(1);
                     12: var_dump(inet_ntop((binary)$packed));
                     13: 
                     14: $packed = chr(255) . chr(255) . chr(255) . chr(0);
                     15: var_dump(inet_ntop((binary)$packed));
                     16: 
                     17: var_dump(inet_ntop());
                     18: var_dump(inet_ntop(-1));
                     19: var_dump(inet_ntop(b""));
                     20: var_dump(inet_ntop(b"blah-blah"));
                     21: 
                     22: var_dump(inet_pton());
                     23: var_dump(inet_pton(b""));
                     24: var_dump(inet_pton(-1));
                     25: var_dump(inet_pton(b"abra"));
                     26: 
                     27: $array = array(
                     28:        b"127.0.0.1",
                     29:        b"66.163.161.116",
                     30:        b"255.255.255.255",
                     31:        b"0.0.0.0",
                     32:        );
                     33: foreach ($array as $val) {
                     34:        var_dump(bin2hex($packed = inet_pton($val)));
                     35:        var_dump(inet_ntop($packed));
                     36: }
                     37: 
                     38: echo "Done\n";
                     39: ?>
                     40: --EXPECTF--    
                     41: %unicode|string%(9) "127.0.0.1"
                     42: %unicode|string%(13) "255.255.255.0"
                     43: 
                     44: Warning: inet_ntop() expects exactly 1 parameter, 0 given in %s on line %d
                     45: bool(false)
                     46: 
                     47: Warning: inet_ntop(): Invalid in_addr value in %s on line %d
                     48: bool(false)
                     49: 
                     50: Warning: inet_ntop(): Invalid in_addr value in %s on line %d
                     51: bool(false)
                     52: 
                     53: Warning: inet_ntop(): Invalid in_addr value in %s on line %d
                     54: bool(false)
                     55: 
                     56: Warning: inet_pton() expects exactly 1 parameter, 0 given in %s on line %d
                     57: bool(false)
                     58: 
                     59: Warning: inet_pton(): Unrecognized address  in %s on line %d
                     60: bool(false)
                     61: 
                     62: Warning: inet_pton(): Unrecognized address -1 in %s on line %d
                     63: bool(false)
                     64: 
                     65: Warning: inet_pton(): Unrecognized address abra in %s on line %d
                     66: bool(false)
                     67: %unicode|string%(%d) "7f000001"
                     68: %unicode|string%(9) "127.0.0.1"
                     69: %unicode|string%(%d) "42a3a174"
                     70: %unicode|string%(14) "66.163.161.116"
                     71: %unicode|string%(%d) "ffffffff"
                     72: %unicode|string%(15) "255.255.255.255"
                     73: %unicode|string%(%d) "00000000"
                     74: %unicode|string%(7) "0.0.0.0"
                     75: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>