mirror of
https://github.com/facebook/zstd.git
synced 2025-07-07 12:01:15 +03:00
added a test for ZSTD_compressSequencesAndLiterals
checks that srcSize is present in the frame header and bounds the window size.
This commit is contained in:
@ -3880,7 +3880,7 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : ZSTD_compressSequencesAndLiterals : ", testNb++);
|
||||
{
|
||||
const size_t srcSize = 500 KB;
|
||||
const size_t srcSize = 497000;
|
||||
const BYTE* const src = (BYTE*)CNBuffer;
|
||||
BYTE* const dst = (BYTE*)compressedBuffer;
|
||||
const size_t dstCapacity = ZSTD_compressBound(srcSize);
|
||||
@ -3929,6 +3929,21 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
goto _output_error;
|
||||
}
|
||||
}
|
||||
{ ZSTD_frameHeader zfh;
|
||||
size_t const zfhStatus = ZSTD_getFrameHeader(&zfh, dst, compressedSize);
|
||||
if (zfhStatus != 0) {
|
||||
DISPLAY("Error reading frame header\n");
|
||||
goto _output_error;
|
||||
}
|
||||
if (zfh.frameContentSize != srcSize) {
|
||||
DISPLAY("Error: ZSTD_compressSequencesAndLiterals() did not report srcSize in the frame header\n");
|
||||
goto _output_error;
|
||||
}
|
||||
if (zfh.windowSize > srcSize) {
|
||||
DISPLAY("Error: ZSTD_compressSequencesAndLiterals() did not resized window size to smaller contentSize\n");
|
||||
goto _output_error;
|
||||
}
|
||||
}
|
||||
{ size_t const dSize = ZSTD_decompress(decompressBuffer, decompressSize, dst, compressedSize);
|
||||
if (ZSTD_isError(dSize)) {
|
||||
DISPLAY("Error during decompression of frame produced by ZSTD_compressSequencesAndLiterals()\n");
|
||||
|
Reference in New Issue
Block a user