1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-01 09:47:01 +03:00

Merge pull request #3403 from facebook/setCParams

ZSTD_CCtx_setCParams
This commit is contained in:
Yann Collet
2022-12-28 14:07:13 -08:00
committed by GitHub
3 changed files with 58 additions and 13 deletions

View File

@ -463,9 +463,9 @@ _output_error:
* Unit tests
=============================================*/
static void test_compressBound(int tnb)
static void test_compressBound(unsigned tnb)
{
DISPLAYLEVEL(3, "test%3i : compressBound : ", tnb);
DISPLAYLEVEL(3, "test%3u : compressBound : ", tnb);
/* check ZSTD_compressBound == ZSTD_COMPRESSBOUND
* for a large range of known valid values */
@ -485,9 +485,9 @@ static void test_compressBound(int tnb)
DISPLAYLEVEL(3, "OK \n");
}
static void test_decompressBound(int tnb)
static void test_decompressBound(unsigned tnb)
{
DISPLAYLEVEL(3, "test%3i : decompressBound : ", tnb);
DISPLAYLEVEL(3, "test%3u : decompressBound : ", tnb);
// Simple compression, with size : should provide size;
{ const char example[] = "abcd";
@ -538,6 +538,26 @@ static void test_decompressBound(int tnb)
DISPLAYLEVEL(3, "OK \n");
}
static void test_setCParams(unsigned tnb)
{
ZSTD_CCtx* const cctx = ZSTD_createCCtx();
ZSTD_compressionParameters cparams;
assert(cctx);
DISPLAYLEVEL(3, "test%3u : ZSTD_CCtx_setCParams : ", tnb);
/* valid cparams */
cparams = ZSTD_getCParams(1, 0, 0);
CHECK_Z(ZSTD_CCtx_setCParams(cctx, cparams));
/* invalid cparams (must fail) */
cparams.windowLog = 99;
CHECK(ZSTD_isError(ZSTD_CCtx_setCParams(cctx, cparams)));
free(cctx);
DISPLAYLEVEL(3, "OK \n");
}
static int basicUnitTests(U32 const seed, double compressibility)
{
size_t const CNBuffSize = 5 MB;
@ -588,6 +608,8 @@ static int basicUnitTests(U32 const seed, double compressibility)
test_decompressBound(testNb++);
test_setCParams(testNb++);
DISPLAYLEVEL(3, "test%3u : ZSTD_adjustCParams : ", testNb++);
{
ZSTD_compressionParameters params;