mirror of
https://github.com/facebook/zstd.git
synced 2025-04-26 14:49:18 +03:00
Added test for multiple blocks of zeros and fixed nit about comments
This commit is contained in:
parent
96201d9774
commit
e5704bbfdf
@ -2283,7 +2283,7 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
|
|||||||
/* This the upper bound for the length of an rle block.
|
/* This the upper bound for the length of an rle block.
|
||||||
* This isn't the actual upper bound. Finding the real threshold
|
* This isn't the actual upper bound. Finding the real threshold
|
||||||
* needs further investigation.
|
* needs further investigation.
|
||||||
*/
|
*/
|
||||||
const U32 rleMaxLength = 25;
|
const U32 rleMaxLength = 25;
|
||||||
size_t cSize;
|
size_t cSize;
|
||||||
const BYTE* ip = (const BYTE*)src;
|
const BYTE* ip = (const BYTE*)src;
|
||||||
@ -2310,7 +2310,7 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
|
|||||||
/* We don't want to emit our first block as a RLE even if it qualifies because
|
/* We don't want to emit our first block as a RLE even if it qualifies because
|
||||||
* doing so will cause the decoder to throw a "should consume all input error."
|
* doing so will cause the decoder to throw a "should consume all input error."
|
||||||
* https://github.com/facebook/zstd/blob/dev/programs/fileio.c#L1723
|
* https://github.com/facebook/zstd/blob/dev/programs/fileio.c#L1723
|
||||||
*/
|
*/
|
||||||
!zc->isFirstBlock &&
|
!zc->isFirstBlock &&
|
||||||
cSize < rleMaxLength &&
|
cSize < rleMaxLength &&
|
||||||
ZSTD_isRLE(ip, srcSize))
|
ZSTD_isRLE(ip, srcSize))
|
||||||
|
@ -1960,6 +1960,19 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
|||||||
DISPLAYLEVEL(3, "OK \n");
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Multiple blocks of zeros test */
|
||||||
|
#define LONGZEROSLENGTH 1000000 /* 1MB of zeros */
|
||||||
|
DISPLAYLEVEL(3, "test%3i : compress %u zeroes : ", testNb++, LONGZEROSLENGTH);
|
||||||
|
memset(CNBuffer, 0, LONGZEROSLENGTH);
|
||||||
|
CHECK_VAR(cSize, ZSTD_compress(compressedBuffer, ZSTD_compressBound(LONGZEROSLENGTH), CNBuffer, LONGZEROSLENGTH, 1) );
|
||||||
|
DISPLAYLEVEL(3, "OK (%u bytes : %.2f%%)\n", (unsigned)cSize, (double)cSize/LONGZEROSLENGTH*100);
|
||||||
|
|
||||||
|
DISPLAYLEVEL(3, "test%3i : decompress %u zeroes : ", testNb++, LONGZEROSLENGTH);
|
||||||
|
{ CHECK_NEWV(r, ZSTD_decompress(decodedBuffer, LONGZEROSLENGTH, compressedBuffer, cSize) );
|
||||||
|
if (r != LONGZEROSLENGTH) goto _output_error; }
|
||||||
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
|
|
||||||
/* All zeroes test (test bug #137) */
|
/* All zeroes test (test bug #137) */
|
||||||
#define ZEROESLENGTH 100
|
#define ZEROESLENGTH 100
|
||||||
DISPLAYLEVEL(3, "test%3i : compress %u zeroes : ", testNb++, ZEROESLENGTH);
|
DISPLAYLEVEL(3, "test%3i : compress %u zeroes : ", testNb++, ZEROESLENGTH);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user