Add unit test
This commit is contained in:
+9
-4
@@ -1570,6 +1570,11 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
|||||||
int const segs = 4;
|
int const segs = 4;
|
||||||
/* only use the first half so we don't push against size limit of compressedBuffer */
|
/* only use the first half so we don't push against size limit of compressedBuffer */
|
||||||
size_t const segSize = (CNBuffSize / 2) / segs;
|
size_t const segSize = (CNBuffSize / 2) / segs;
|
||||||
|
|
||||||
|
U32 skippableSize;
|
||||||
|
const U32 skipLen = 129 KB;
|
||||||
|
char* skipBuff = (char*)malloc(skipLen);
|
||||||
|
memset(skipBuff, 0, skipLen);
|
||||||
for (i = 0; i < segs; i++) {
|
for (i = 0; i < segs; i++) {
|
||||||
CHECK_NEWV(r, ZSTD_compress(
|
CHECK_NEWV(r, ZSTD_compress(
|
||||||
(BYTE*)compressedBuffer + off, CNBuffSize - off,
|
(BYTE*)compressedBuffer + off, CNBuffSize - off,
|
||||||
@@ -1578,13 +1583,13 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
|||||||
off += r;
|
off += r;
|
||||||
if (i == segs/2) {
|
if (i == segs/2) {
|
||||||
/* insert skippable frame */
|
/* insert skippable frame */
|
||||||
const U32 skipLen = 129 KB;
|
skippableSize = ZSTD_generateSkippableFrame(compressedBuffer + off, compressedBufferSize, skipBuff, skipLen, seed % 15);
|
||||||
MEM_writeLE32((BYTE*)compressedBuffer + off, ZSTD_MAGIC_SKIPPABLE_START);
|
CHECK_Z(skippableSize);
|
||||||
MEM_writeLE32((BYTE*)compressedBuffer + off + 4, skipLen);
|
off += skippableSize;
|
||||||
off += skipLen + ZSTD_SKIPPABLEHEADERSIZE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cSize = off;
|
cSize = off;
|
||||||
|
free(skipBuff);
|
||||||
}
|
}
|
||||||
DISPLAYLEVEL(3, "OK \n");
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user