Skip to content

Commit cd3b044

Browse files
author
Ivan Kishchenko
committed
phpt for str8 for ticket #40
1 parent 106ef6f commit cd3b044

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/137.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
unpack/pack str8
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+
function test() {
11+
if(!extension_loaded('msgpack'))
12+
{
13+
dl('msgpack.' . PHP_SHLIB_SUFFIX);
14+
}
15+
16+
$str = "Simple test for short string - type str8";
17+
$str8 = chr(0xD9) . chr(strlen($str)) . $str;
18+
echo msgpack_unpack($str8) . "\n";
19+
$data = msgpack_pack($str);
20+
echo ($data[0] == chr(0xD9) && $data[1] == chr(strlen($str)) ? "OK" : "FAILED"), PHP_EOL;
21+
}
22+
23+
test();
24+
?>
25+
--EXPECTF--
26+
Simple test for short string - type str8
27+
OK

0 commit comments

Comments
 (0)