File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ unpack bin format family
3+ --SKIPIF--
4+ <?php
5+ if (version_compare (PHP_VERSION , '5.2.0 ' ) < 0 ) {
6+ echo "skip tests in PHP 5.2 or newer " ;
7+ }
8+ --FILE --
9+ <?php
10+ if (!extension_loaded ('msgpack ' )) {
11+ dl ('msgpack. ' . PHP_SHLIB_SUFFIX );
12+ }
13+
14+ $ bin8_serialized = pack ('H* ' , 'c40962696e382074657374 ' );
15+ $ bin8_unserialized = msgpack_unpack ($ bin8_serialized );
16+ var_dump ($ bin8_unserialized );
17+ echo ($ bin8_unserialized == "bin8 test " ) ? "OK " : "FAILED " , PHP_EOL ;
18+
19+ $ bin16_serialized = pack ('H* ' , 'c5000a62696e31362074657374 ' );
20+ $ bin16_unserialized = msgpack_unpack ($ bin16_serialized );
21+ var_dump ($ bin16_unserialized );
22+ echo ($ bin16_unserialized == "bin16 test " ) ? "OK " : "FAILED " , PHP_EOL ;
23+
24+
25+ $ bin32_serialized = pack ('H* ' , 'c60000000a62696e33322074657374 ' );
26+ $ bin32_unserialized = msgpack_unpack ($ bin32_serialized );
27+ var_dump ($ bin32_unserialized );
28+ echo ($ bin32_unserialized == "bin32 test " ) ? "OK " : "FAILED " , PHP_EOL ;
29+ ?>
30+ --EXPECTF--
31+ string(9) "bin8 test"
32+ OK
33+ string(10) "bin16 test"
34+ OK
35+ string(10) "bin32 test"
36+ OK
You can’t perform that action at this time.
0 commit comments