diff options
author | Yann Collet <cyan@fb.com> | 2017-08-09 23:51:19 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-08-09 23:51:19 (GMT) |
commit | 31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad (patch) | |
tree | 5dc0309a412fbf5bf40caea48094115dc4eb9c97 /tests | |
parent | 1d1737aaf28c60d3cf6950b545f6a844afe422c0 (diff) | |
download | lz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.zip lz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.tar.gz lz4-31f2cdf4d214edcd9d4496058b0f9a4c4f8c0fad.tar.bz2 |
implemented dictionary compression in lz4frame
note : only compression API is implemented and tested
still to do : decompression API
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frametest.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/frametest.c b/tests/frametest.c index 02d7e5b..1ee0d96 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -482,10 +482,36 @@ int basicTests(U32 seed, double compressibility) if (prefs.frameInfo.dictID != dictID) goto _output_error; DISPLAYLEVEL(3, "%u \n", (U32)prefs.frameInfo.dictID); - CHECK( LZ4F_freeCompressionContext(cctx) ); cctx = NULL; CHECK( LZ4F_freeDecompressionContext(dCtx) ); dCtx = NULL; + 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; + DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with NULL dict : "); + CHECK_V(cSizeNoDict, + LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + CNBuffer, dictSize, + NULL, NULL) ); + DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeNoDict); + + DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with dict : "); + CHECK_V(cSizeWithDict, + LZ4F_compressFrame_usingCDict(compressedBuffer, dstCapacity, + CNBuffer, dictSize, + cdict, NULL) ); + DISPLAYLEVEL(3, "%u bytes \n", (unsigned)cSizeWithDict); + if (cSizeWithDict >= cSizeNoDict) goto _output_error; /* must be more efficient */ + + LZ4F_freeCDict(cdict); } + DISPLAYLEVEL(3, "Skippable frame test : \n"); { size_t decodedBufferSize = COMPRESSIBLE_NOISE_LENGTH; unsigned maxBits = FUZ_highbit((U32)decodedBufferSize); |