Skip to content

Commit cae88d8

Browse files
committed
Add test 138.phpt(unpack bin format family) for bin format family
1 parent dc75747 commit cae88d8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/138.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

0 commit comments

Comments
 (0)