Files
php-src/ext/bz2/tests/bzcompress_programming_errors.phpt
Gina Peter Banyard d4c88a299b ext/bz2: Check int params of bzcompress() are correct (#16108)
Also add a TODO to check the length of the source strings
2024-09-28 22:38:53 +01:00

40 lines
1.0 KiB
PHP

--TEST--
bzcompress(): providing invalid options
--EXTENSIONS--
bz2
--FILE--
<?php
$string = "Life it seems, will fade away
Drifting further everyday
Getting lost within myself
Nothing matters no one else";
try {
var_dump(bzcompress($string, 0));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(bzcompress($string, 100));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(bzcompress($string, work_factor: -1));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(bzcompress($string, work_factor: 255));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: bzcompress(): Argument #2 ($block_size) must be between 1 and 9
ValueError: bzcompress(): Argument #2 ($block_size) must be between 1 and 9
ValueError: bzcompress(): Argument #3 ($work_factor) must be between 0 and 250
ValueError: bzcompress(): Argument #3 ($work_factor) must be between 0 and 250