Skip to content

Commit 79afa04

Browse files
committed
test: add streaming compressed data with zstd_uncompress_dict()
1 parent 80a5099 commit 79afa04

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/dictionary_02.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
zstd_uncompress_dict(): streaming compress
3+
--SKIPIF--
4+
<?php
5+
if (LIBZSTD_VERSION_NUMBER < 10304) die("skip needs libzstd 1.3.4");
6+
?>
7+
--FILE--
8+
<?php
9+
include(dirname(__FILE__) . '/data.inc');
10+
$dictionary = file_get_contents(dirname(__FILE__) . '/data.dic');
11+
12+
$context = stream_context_create(
13+
array(
14+
'zstd' => array(
15+
'dict' => $dictionary
16+
)
17+
)
18+
);
19+
20+
$file = dirname(__FILE__) . '/data_' . basename(__FILE__, ".php") . '.out';
21+
file_put_contents('compress.zstd://' . $file, $data, 0, $context);
22+
$enc = file_get_contents($file);
23+
24+
$dec = zstd_uncompress_dict($enc, $dictionary);
25+
26+
var_dump($data === $dec);
27+
28+
@unlink($file);
29+
?>
30+
===Done===
31+
--EXPECTF--
32+
bool(true)
33+
===Done===

0 commit comments

Comments
 (0)