diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2022-07-15 12:36:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-15 12:36:46 (GMT) |
commit | 0bd66839ed9a6993196071596307cde18075dd9c (patch) | |
tree | 9705fe4f31402ca5ac79c6962f295fac3b05e968 | |
parent | 0c620ce212d92d009f47293ea5e0b676c3380fbb (diff) | |
parent | 35d58a5ea7fccef9fd08fce6a5f5e6efda7daa57 (diff) | |
download | lz4-0bd66839ed9a6993196071596307cde18075dd9c.zip lz4-0bd66839ed9a6993196071596307cde18075dd9c.tar.gz lz4-0bd66839ed9a6993196071596307cde18075dd9c.tar.bz2 |
Merge pull request #1118 from lz4/fix_dec-part-dict
fix decompress-partial-usingDict.c
-rw-r--r-- | tests/decompress-partial-usingDict.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/tests/decompress-partial-usingDict.c b/tests/decompress-partial-usingDict.c index cfcb971..8b85106 100644 --- a/tests/decompress-partial-usingDict.c +++ b/tests/decompress-partial-usingDict.c @@ -1,6 +1,7 @@ -#include "stdio.h" -#include "string.h" -#include "stdlib.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> #include "lz4.h" const char source[] = @@ -33,27 +34,35 @@ int main(void) size_t const smallSize = 1024; size_t const largeSize = 64 * 1024 - 1; char cmpBuffer[BUFFER_SIZE]; - char buffer[BUFFER_SIZE + largeSize]; + char* const buffer = (char*)malloc(BUFFER_SIZE + largeSize); char* outBuffer = buffer + largeSize; char* const dict = (char*)malloc(largeSize); char* const largeDict = dict; char* const smallDict = dict + largeSize - smallSize; - int cmpSize; int i; + int cmpSize; + + printf("starting test decompress-partial-usingDict : \n"); + assert(buffer != NULL); + assert(dict != NULL); cmpSize = LZ4_compress_default(source, cmpBuffer, srcLen, BUFFER_SIZE); for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, NULL, 0); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with no dict error \n"); return -1; } } - + for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, outBuffer - smallSize, smallSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with small prefix error \n"); return -1; } @@ -61,7 +70,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, buffer, largeSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with large prefix error \n"); return -1; } @@ -69,7 +80,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, smallDict, smallSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with small external dict error \n"); return -1; } @@ -77,7 +90,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, largeDict, largeSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with large external dict error \n"); return -1; } |