added test for decompression with NULL dict and NULL DDict
previous version of ZSTD_decompressMultiFrame() would fail that test
This commit is contained in:
+12
-8
@@ -108,6 +108,7 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
void* const CNBuffer = malloc(CNBuffSize);
|
void* const CNBuffer = malloc(CNBuffSize);
|
||||||
void* const compressedBuffer = malloc(ZSTD_compressBound(CNBuffSize));
|
void* const compressedBuffer = malloc(ZSTD_compressBound(CNBuffSize));
|
||||||
void* const decodedBuffer = malloc(CNBuffSize);
|
void* const decodedBuffer = malloc(CNBuffSize);
|
||||||
|
ZSTD_DCtx* dctx = ZSTD_createDCtx();
|
||||||
int testResult = 0;
|
int testResult = 0;
|
||||||
U32 testNb=0;
|
U32 testNb=0;
|
||||||
size_t cSize;
|
size_t cSize;
|
||||||
@@ -155,6 +156,16 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
} }
|
} }
|
||||||
DISPLAYLEVEL(4, "OK \n");
|
DISPLAYLEVEL(4, "OK \n");
|
||||||
|
|
||||||
|
DISPLAYLEVEL(4, "test%3i : decompress with null dict : ", testNb++);
|
||||||
|
{ size_t const r = ZSTD_decompress_usingDict(dctx, decodedBuffer, CNBuffSize, compressedBuffer, cSize, NULL, 0);
|
||||||
|
if (r != CNBuffSize) goto _output_error; }
|
||||||
|
DISPLAYLEVEL(4, "OK \n");
|
||||||
|
|
||||||
|
DISPLAYLEVEL(4, "test%3i : decompress with null DDict : ", testNb++);
|
||||||
|
{ size_t const r = ZSTD_decompress_usingDDict(dctx, decodedBuffer, CNBuffSize, compressedBuffer, cSize, NULL);
|
||||||
|
if (r != CNBuffSize) goto _output_error; }
|
||||||
|
DISPLAYLEVEL(4, "OK \n");
|
||||||
|
|
||||||
DISPLAYLEVEL(4, "test%3i : decompress with 1 missing byte : ", testNb++);
|
DISPLAYLEVEL(4, "test%3i : decompress with 1 missing byte : ", testNb++);
|
||||||
{ size_t const r = ZSTD_decompress(decodedBuffer, CNBuffSize, compressedBuffer, cSize-1);
|
{ size_t const r = ZSTD_decompress(decodedBuffer, CNBuffSize, compressedBuffer, cSize-1);
|
||||||
if (!ZSTD_isError(r)) goto _output_error;
|
if (!ZSTD_isError(r)) goto _output_error;
|
||||||
@@ -210,7 +221,6 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
/* Dictionary and CCtx Duplication tests */
|
/* Dictionary and CCtx Duplication tests */
|
||||||
{ ZSTD_CCtx* const ctxOrig = ZSTD_createCCtx();
|
{ ZSTD_CCtx* const ctxOrig = ZSTD_createCCtx();
|
||||||
ZSTD_CCtx* const ctxDuplicated = ZSTD_createCCtx();
|
ZSTD_CCtx* const ctxDuplicated = ZSTD_createCCtx();
|
||||||
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
|
||||||
static const size_t dictSize = 551;
|
static const size_t dictSize = 551;
|
||||||
|
|
||||||
DISPLAYLEVEL(4, "test%3i : copy context too soon : ", testNb++);
|
DISPLAYLEVEL(4, "test%3i : copy context too soon : ", testNb++);
|
||||||
@@ -283,12 +293,10 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
|
|
||||||
ZSTD_freeCCtx(ctxOrig);
|
ZSTD_freeCCtx(ctxOrig);
|
||||||
ZSTD_freeCCtx(ctxDuplicated);
|
ZSTD_freeCCtx(ctxDuplicated);
|
||||||
ZSTD_freeDCtx(dctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dictionary and dictBuilder tests */
|
/* Dictionary and dictBuilder tests */
|
||||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||||
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
|
||||||
size_t dictSize = 16 KB;
|
size_t dictSize = 16 KB;
|
||||||
void* dictBuffer = malloc(dictSize);
|
void* dictBuffer = malloc(dictSize);
|
||||||
size_t const totalSampleSize = 1 MB;
|
size_t const totalSampleSize = 1 MB;
|
||||||
@@ -370,14 +378,12 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
DISPLAYLEVEL(4, "OK \n");
|
DISPLAYLEVEL(4, "OK \n");
|
||||||
|
|
||||||
ZSTD_freeCCtx(cctx);
|
ZSTD_freeCCtx(cctx);
|
||||||
ZSTD_freeDCtx(dctx);
|
|
||||||
free(dictBuffer);
|
free(dictBuffer);
|
||||||
free(samplesSizes);
|
free(samplesSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* COVER dictionary builder tests */
|
/* COVER dictionary builder tests */
|
||||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||||
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
|
||||||
size_t dictSize = 16 KB;
|
size_t dictSize = 16 KB;
|
||||||
size_t optDictSize = dictSize;
|
size_t optDictSize = dictSize;
|
||||||
void* dictBuffer = malloc(dictSize);
|
void* dictBuffer = malloc(dictSize);
|
||||||
@@ -414,7 +420,7 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
memset(¶ms, 0, sizeof(params));
|
memset(¶ms, 0, sizeof(params));
|
||||||
params.steps = 4;
|
params.steps = 4;
|
||||||
optDictSize = COVER_optimizeTrainFromBuffer(dictBuffer, optDictSize,
|
optDictSize = COVER_optimizeTrainFromBuffer(dictBuffer, optDictSize,
|
||||||
CNBuffer, samplesSizes, nbSamples,
|
CNBuffer, samplesSizes, nbSamples / 4,
|
||||||
¶ms);
|
¶ms);
|
||||||
if (ZDICT_isError(optDictSize)) goto _output_error;
|
if (ZDICT_isError(optDictSize)) goto _output_error;
|
||||||
DISPLAYLEVEL(4, "OK, created dictionary of size %u \n", (U32)optDictSize);
|
DISPLAYLEVEL(4, "OK, created dictionary of size %u \n", (U32)optDictSize);
|
||||||
@@ -425,7 +431,6 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
DISPLAYLEVEL(4, "OK : %u \n", dictID);
|
DISPLAYLEVEL(4, "OK : %u \n", dictID);
|
||||||
|
|
||||||
ZSTD_freeCCtx(cctx);
|
ZSTD_freeCCtx(cctx);
|
||||||
ZSTD_freeDCtx(dctx);
|
|
||||||
free(dictBuffer);
|
free(dictBuffer);
|
||||||
free(samplesSizes);
|
free(samplesSizes);
|
||||||
}
|
}
|
||||||
@@ -445,7 +450,6 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
|
|
||||||
/* block API tests */
|
/* block API tests */
|
||||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||||
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
|
||||||
static const size_t dictSize = 65 KB;
|
static const size_t dictSize = 65 KB;
|
||||||
static const size_t blockSize = 100 KB; /* won't cause pb with small dict size */
|
static const size_t blockSize = 100 KB; /* won't cause pb with small dict size */
|
||||||
size_t cSize2;
|
size_t cSize2;
|
||||||
|
|||||||
Reference in New Issue
Block a user