mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-20 07:15:35 +08:00
unify tests for all compression extensions
This commit is contained in:
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
$str = 'brotli_compress ( string $data, int $level = BROTLI_COMPRESS_LEVEL_DEFAULT, int $mode = BROTLI_GENERIC, string|null $dict = null ): string|false';
|
|
||||||
assert(function_exists('brotli_compress'));
|
assert(function_exists('brotli_compress'));
|
||||||
assert(function_exists('brotli_uncompress'));
|
assert(function_exists('brotli_uncompress'));
|
||||||
assert(brotli_uncompress(brotli_compress($str)) === $str);
|
|
||||||
|
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
|
||||||
|
$compressed = brotli_compress($input);
|
||||||
|
assert(is_string($compressed));
|
||||||
|
assert(strlen($compressed) < strlen($input));
|
||||||
|
|
||||||
|
$uncompressed = brotli_uncompress($compressed);
|
||||||
|
assert(is_string($uncompressed));
|
||||||
|
assert($uncompressed === $input);
|
||||||
|
|||||||
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
$str = 'This is bz2 extension test';
|
|
||||||
assert(function_exists('bzdecompress'));
|
|
||||||
assert(function_exists('bzcompress'));
|
assert(function_exists('bzcompress'));
|
||||||
assert(bzdecompress(bzcompress($str, 9)) === $str);
|
assert(function_exists('bzdecompress'));
|
||||||
|
|
||||||
|
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
|
||||||
|
$compressed = bzcompress($input);
|
||||||
|
assert(is_string($compressed));
|
||||||
|
assert(strlen($compressed) < strlen($input));
|
||||||
|
|
||||||
|
$uncompressed = bzdecompress($compressed);
|
||||||
|
assert(is_string($uncompressed));
|
||||||
|
assert($uncompressed === $input);
|
||||||
|
|||||||
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
$str = 'Data you would like compressed.';
|
|
||||||
assert(function_exists('xzencode'));
|
assert(function_exists('xzencode'));
|
||||||
assert(function_exists('xzdecode'));
|
assert(function_exists('xzdecode'));
|
||||||
assert(xzdecode(xzencode($str)) === $str);
|
|
||||||
|
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
|
||||||
|
$compressed = xzencode($input);
|
||||||
|
assert(is_string($compressed));
|
||||||
|
assert(strlen($compressed) < strlen($input));
|
||||||
|
|
||||||
|
$uncompressed = xzdecode($compressed);
|
||||||
|
assert(is_string($uncompressed));
|
||||||
|
assert($uncompressed === $input);
|
||||||
|
|||||||
@@ -3,4 +3,13 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
assert(function_exists('gzcompress'));
|
assert(function_exists('gzcompress'));
|
||||||
assert(gzdecode(gzencode('aaa')) === 'aaa');
|
assert(function_exists('gzdecode'));
|
||||||
|
|
||||||
|
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
|
||||||
|
$compressed = gzcompress($input);
|
||||||
|
assert(is_string($compressed));
|
||||||
|
assert(strlen($compressed) < strlen($input));
|
||||||
|
|
||||||
|
$uncompressed = gzdecode($compressed);
|
||||||
|
assert(is_string($uncompressed));
|
||||||
|
assert($uncompressed === $input);
|
||||||
|
|||||||
15
src/globals/ext-tests/zstd.php
Normal file
15
src/globals/ext-tests/zstd.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
assert(function_exists('zstd_compress'));
|
||||||
|
assert(function_exists('zstd_uncompress'));
|
||||||
|
|
||||||
|
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
|
||||||
|
$compressed = zstd_compress($input);
|
||||||
|
assert(is_string($compressed));
|
||||||
|
assert(strlen($compressed) < strlen($input));
|
||||||
|
|
||||||
|
$uncompressed = zstd_uncompress($compressed);
|
||||||
|
assert(is_string($uncompressed));
|
||||||
|
assert($uncompressed === $input);
|
||||||
Reference in New Issue
Block a user