mirror of
https://github.com/facebook/zstd
synced 2026-08-22 22:32:07 -04:00
added tests
check that ZSTD_compressAndLiterals() also controls that the `srcSize` field is exact.
This commit is contained in:
parent
31b5ef2539
commit
f0d0d95234
1 changed files with 14 additions and 0 deletions
|
|
@ -3922,6 +3922,20 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
|||
goto _output_error;
|
||||
}
|
||||
|
||||
/* too short srcSize: must fail */
|
||||
compressedSize = ZSTD_compressSequencesAndLiterals(cctx, dst, dstCapacity, seqs, nbSeqs, src, litSize, srcSize-1);
|
||||
if (!ZSTD_isError(compressedSize)) {
|
||||
DISPLAY("ZSTD_compressSequencesAndLiterals() should have failed: srcSize is too short\n");
|
||||
goto _output_error;
|
||||
}
|
||||
|
||||
/* too large srcSize: must fail */
|
||||
compressedSize = ZSTD_compressSequencesAndLiterals(cctx, dst, dstCapacity, seqs, nbSeqs, src, litSize, srcSize+1);
|
||||
if (!ZSTD_isError(compressedSize)) {
|
||||
DISPLAY("ZSTD_compressSequencesAndLiterals() should have failed: srcSize is too short\n");
|
||||
goto _output_error;
|
||||
}
|
||||
|
||||
/* correct amount of literals: should compress successfully */
|
||||
compressedSize = ZSTD_compressSequencesAndLiterals(cctx, dst, dstCapacity, seqs, nbSeqs, litBuffer, litSize, srcSize);
|
||||
if (ZSTD_isError(compressedSize)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue