Skip to content

Commit 9d5ce7e

Browse files
committed
test: add stream for zstd_uncompress_dict()
1 parent 3bc460e commit 9d5ce7e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/dictionary_02.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
zstd_uncompress_dict(): streaming archive
3+
--FILE--
4+
<?php
5+
include(dirname(__FILE__) . '/data.inc');
6+
7+
$file = dirname(__FILE__) . '/data_' . basename(__FILE__, ".php") . '.out';
8+
$dictionary = file_get_contents(dirname(__FILE__) . '/data.dic');
9+
10+
echo "Compression\n";
11+
12+
$ctx = stream_context_create(
13+
array(
14+
"zstd" => array(
15+
"level" => ZSTD_COMPRESS_LEVEL_DEFAULT,
16+
"dict" => $dictionary,
17+
)
18+
)
19+
);
20+
21+
var_dump(file_put_contents('compress.zstd://' . $file, $data, 0, $ctx) == strlen($data));
22+
23+
echo "Decompression\n";
24+
25+
var_dump(zstd_uncompress_dict(file_get_contents($file), $dictionary) === $data);
26+
27+
@unlink($file);
28+
?>
29+
===Done===
30+
--EXPECTF--
31+
Compression
32+
bool(true)
33+
Decompression
34+
bool(true)
35+
===Done===

0 commit comments

Comments
 (0)