summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-01-26 16:29:00 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-03-12 18:58:43 (GMT)
commit9dcd9abc14a33b6ac6c91dd727235db1daabe066 (patch)
tree47a7244a9af9ae81e2a0fcb2547eb50f1f4349e5 /tests
parent14ce912b705db03bd1d723456dd1a3242b7f7ea7 (diff)
downloadlz4-9dcd9abc14a33b6ac6c91dd727235db1daabe066.zip
lz4-9dcd9abc14a33b6ac6c91dd727235db1daabe066.tar.gz
lz4-9dcd9abc14a33b6ac6c91dd727235db1daabe066.tar.bz2
Make LZ4F_compressFrame_usingCDict Take a Compression Context
Diffstat (limited to 'tests')
-rw-r--r--tests/framebench.c2
-rw-r--r--tests/frametest.c19
2 files changed, 13 insertions, 8 deletions
diff --git a/tests/framebench.c b/tests/framebench.c
index 21c3704..a7a270b 100644
--- a/tests/framebench.c
+++ b/tests/framebench.c
@@ -30,6 +30,7 @@ typedef struct {
size_t compress_frame(bench_params_t *p) {
size_t iter = p->iter;
+ LZ4F_cctx *cctx = p->cctx;
char *obuf = p->obuf;
size_t osize = p->osize;
const char* ibuf = p->ibuf;
@@ -43,6 +44,7 @@ size_t compress_frame(bench_params_t *p) {
prefs->frameInfo.contentSize = isize;
oused = LZ4F_compressFrame_usingCDict(
+ cctx,
obuf,
osize,
ibuf + ((iter * 2654435761U) % num_ibuf) * isize,
diff --git a/tests/frametest.c b/tests/frametest.c
index 986a16d..74d9c88 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -164,7 +164,7 @@ static unsigned FUZ_highbit(U32 v32)
/*-*******************************************************
* Tests
*********************************************************/
-#define CHECK_V(v,f) v = f; if (LZ4F_isError(v)) goto _output_error
+#define CHECK_V(v,f) v = f; if (LZ4F_isError(v)) { fprintf(stderr, "%s\n", LZ4F_getErrorName(v)); goto _output_error; }
#define CHECK(f) { LZ4F_errorCode_t const CHECK_V(err_ , f); }
int basicTests(U32 seed, double compressibility)
@@ -509,23 +509,25 @@ int basicTests(U32 seed, double compressibility)
CHECK( LZ4F_freeCompressionContext(cctx) ); cctx = NULL;
}
-
/* Dictionary compression test */
{ size_t const dictSize = 63 KB;
size_t const dstCapacity = LZ4F_compressFrameBound(dictSize, NULL);
size_t cSizeNoDict, cSizeWithDict;
LZ4F_CDict* const cdict = LZ4F_createCDict(CNBuffer, dictSize);
if (cdict == NULL) goto _output_error;
+ CHECK( LZ4F_createCompressionContext(&cctx, LZ4F_VERSION) );
DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with NULL dict : ");
CHECK_V(cSizeNoDict,
- LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity,
CNBuffer, dictSize,
NULL, NULL) );
DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeNoDict);
+ CHECK( LZ4F_freeCompressionContext(cctx) );
+ CHECK( LZ4F_createCompressionContext(&cctx, LZ4F_VERSION) );
DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with dict : ");
CHECK_V(cSizeWithDict,
- LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity,
CNBuffer, dictSize,
cdict, NULL) );
DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n",
@@ -557,7 +559,7 @@ int basicTests(U32 seed, double compressibility)
memset(&cParams, 0, sizeof(cParams));
cParams.compressionLevel = -3;
CHECK_V(cSizeLevelMax,
- LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity,
CNBuffer, dictSize,
cdict, &cParams) );
DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeLevelMax);
@@ -569,7 +571,7 @@ int basicTests(U32 seed, double compressibility)
memset(&cParams, 0, sizeof(cParams));
cParams.compressionLevel = LZ4F_compressionLevel_max();
CHECK_V(cSizeLevelMax,
- LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity,
CNBuffer, dictSize,
cdict, &cParams) );
DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeLevelMax);
@@ -584,7 +586,7 @@ int basicTests(U32 seed, double compressibility)
cParams.frameInfo.blockMode = LZ4F_blockLinked;
cParams.frameInfo.blockSizeID = LZ4F_max64KB;
CHECK_V(cSizeContiguous,
- LZ4F_compressFrame_usingCDict(compressedBuffer, outCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, outCapacity,
CNBuffer, inSize,
cdict, &cParams) );
DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n",
@@ -620,7 +622,7 @@ int basicTests(U32 seed, double compressibility)
cParams.frameInfo.blockMode = LZ4F_blockIndependent;
cParams.frameInfo.blockSizeID = LZ4F_max64KB;
CHECK_V(cSizeIndep,
- LZ4F_compressFrame_usingCDict(compressedBuffer, outCapacity,
+ LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, outCapacity,
CNBuffer, inSize,
cdict, &cParams) );
DISPLAYLEVEL(3, "compressed %u bytes into %u bytes \n",
@@ -647,6 +649,7 @@ int basicTests(U32 seed, double compressibility)
}
LZ4F_freeCDict(cdict);
+ CHECK( LZ4F_freeCompressionContext(cctx) ); cctx = NULL;
}