summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-09-03 18:49:59 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-09-03 18:49:59 (GMT)
commite619cfe8525f16d382fad1c569c1b71b25ac3d1d (patch)
tree2ab447dc10962965c33da806ea617c530cab219b /programs
parentf7f67e778c9261fa5843811068f3eb3cc4e70509 (diff)
downloadlz4-e619cfe8525f16d382fad1c569c1b71b25ac3d1d.zip
lz4-e619cfe8525f16d382fad1c569c1b71b25ac3d1d.tar.gz
lz4-e619cfe8525f16d382fad1c569c1b71b25ac3d1d.tar.bz2
Completed first version of lz4frame decompress
Added a first decompression test
Diffstat (limited to 'programs')
-rw-r--r--programs/frametest.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/programs/frametest.c b/programs/frametest.c
index e61205a..2b52190 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -187,6 +187,7 @@ int frameTest(U32 seed, int nbCycles, int startCycle, double compressibility)
U32 randState = seed;
size_t cSize, testSize;
LZ4F_preferences_t prefs = { 0 };
+ LZ4F_decompressionContext_t dCtx;
(void)nbCycles; (void)startCycle;
// Create compressible test buffer
@@ -202,6 +203,19 @@ int frameTest(U32 seed, int nbCycles, int startCycle, double compressibility)
if (LZ4F_isError(cSize)) goto _output_error;
DISPLAY("Compressed %i bytes into a %i bytes frame \n", (int)testSize, (int)cSize);
+ DISPLAY("Decompression test : \n");
+ {
+ LZ4F_errorCode_t errorCode = LZ4F_createDecompressionContext(&dCtx);
+ size_t decodedBufferSize = COMPRESSIBLE_NOISE_LENGTH;
+ size_t compressedBufferSize = cSize;
+ if (LZ4F_isError(errorCode)) goto _output_error;
+ errorCode = LZ4F_decompress(dCtx, decodedBuffer, &decodedBufferSize, compressedBuffer, &compressedBufferSize, NULL);
+ if (LZ4F_isError(errorCode)) goto _output_error;
+ DISPLAY("Regenerated %i bytes \n", (int)decodedBufferSize);
+ errorCode = LZ4F_freeDecompressionContext(dCtx);
+ if (LZ4F_isError(errorCode)) goto _output_error;
+ }
+
DISPLAY("Using 64 KB block : \n");
prefs.frameInfo.blockSizeID = max64KB;
cSize = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(testSize, &(prefs.frameInfo)), CNBuffer, testSize, &prefs);
@@ -262,6 +276,7 @@ _end:
_output_error:
testResult = 1;
+ DISPLAY("Error detected ! \n");
if(!no_prompt) getchar();
goto _end;
}