Update unit tests

This commit is contained in:
senhuang42 2020-11-06 10:56:56 -05:00
parent 779df995c6
commit 7d1dea070c
3 changed files with 11 additions and 11 deletions

View File

@ -2570,7 +2570,7 @@ size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
return zc->seqCollector.seqIndex; return zc->seqCollector.seqIndex;
} }
size_t ZSTD_mergeGeneratedSequences(ZSTD_Sequence* sequences, size_t seqsSize) { size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize) {
size_t in = 0; size_t in = 0;
size_t out = 0; size_t out = 0;
for (; in < seqsSize; ++in) { for (; in < seqsSize; ++in) {

View File

@ -1303,10 +1303,12 @@ typedef enum {
} ZSTD_sequenceFormat_e; } ZSTD_sequenceFormat_e;
/*! ZSTD_generateSequences() : /*! ZSTD_generateSequences() :
* Extract sequences from the sequence store. * Generate sequences using ZSTD_compress2, given a source buffer.
* *
* Each block will end with a dummy sequence * Each block will end with a dummy sequence
* with offset == 0, matchLength == 0, and litLength == length of last literals. * with offset == 0, matchLength == 0, and litLength == length of last literals.
* litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
* simply acts as a block delimiter.
* *
* zc can be used to insert custom compression params. * zc can be used to insert custom compression params.
* This function invokes ZSTD_compress2 * This function invokes ZSTD_compress2
@ -1316,17 +1318,15 @@ typedef enum {
ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs, ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
size_t outSeqsSize, const void* src, size_t srcSize); size_t outSeqsSize, const void* src, size_t srcSize);
/*! ZSTD_mergeGeneratedSequences() : /*! ZSTD_mergeBlockDelimiters() :
* Convert an array of ZSTD_Sequence in the representation specified in ZSTD_generateSequences() * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
* and merge all "dummy" sequences that represent last literals and block boundaries. * by merging them into into the literals of the next sequence.
*
* Any last literals in the block will be merged into the literals of the next sequence.
* *
* As such, the final generated result has no explicit representation of block boundaries, * As such, the final generated result has no explicit representation of block boundaries,
* and the final last literals segment is not represented in the sequences. * and the final last literals segment is not represented in the sequences.
* @return : number of sequences in final result * @return : number of sequences left after merging
*/ */
ZSTDLIB_API size_t ZSTD_mergeGeneratedSequences(ZSTD_Sequence* sequences, size_t seqsSize); ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
/*************************************** /***************************************
* Memory management * Memory management

View File

@ -2725,12 +2725,12 @@ static int basicUnitTests(U32 const seed, double compressibility)
RDG_genBuffer(CNBuffer, srcSize, compressibility, 0., seed); RDG_genBuffer(CNBuffer, srcSize, compressibility, 0., seed);
/* Test with block delimiters roundtrip */ /* Test with block delimiters roundtrip */
seqsSize = ZSTD_generateSequences(cctx, seqs, srcSize, src, srcSize, ZSTD_sf_explicitBlockDelimiters); seqsSize = ZSTD_generateSequences(cctx, seqs, srcSize, src, srcSize);
FUZ_decodeSequences(decoded, seqs, seqsSize, src, srcSize, ZSTD_sf_explicitBlockDelimiters); FUZ_decodeSequences(decoded, seqs, seqsSize, src, srcSize, ZSTD_sf_explicitBlockDelimiters);
assert(!memcmp(CNBuffer, compressedBuffer, srcSize)); assert(!memcmp(CNBuffer, compressedBuffer, srcSize));
/* Test no block delimiters roundtrip */ /* Test no block delimiters roundtrip */
seqsSize = ZSTD_generateSequences(cctx, seqs, srcSize, src, srcSize, ZSTD_sf_noBlockDelimiters); seqsSize = ZSTD_mergeBlockDelimiters(seqs, seqsSize);
FUZ_decodeSequences(decoded, seqs, seqsSize, src, srcSize, ZSTD_sf_noBlockDelimiters); FUZ_decodeSequences(decoded, seqs, seqsSize, src, srcSize, ZSTD_sf_noBlockDelimiters);
assert(!memcmp(CNBuffer, compressedBuffer, srcSize)); assert(!memcmp(CNBuffer, compressedBuffer, srcSize));