From: Yann Collet Date: Tue, 18 Apr 2017 22:08:52 +0000 (-0700) Subject: added test for ZSTD_initCStream_advanced() X-Git-Tag: v1.2.0^2~34^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bb381dad88105946728d04c3ea45c19204c2636;p=thirdparty%2Fzstd.git added test for ZSTD_initCStream_advanced() when params.fParams.contentSizeFlags = 1 and pledgedSrcSize = 0 then srcSize should be considered 0 (empty), and not "unknown" --- diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index ac200a7a6..6673208b0 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c @@ -479,7 +479,24 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo DISPLAYLEVEL(3, "OK (%s)\n", ZSTD_getErrorName(r)); } - /* Unknown srcSize */ + /* Empty srcSize */ + DISPLAYLEVEL(3, "test%3i : ZSTD_initCStream_advanced with pledgedSrcSize=0 and dict : ", testNb++); + { ZSTD_parameters params = ZSTD_getParams(5, 0, 0); + params.fParams.contentSizeFlag = 1; + ZSTD_initCStream_advanced(zc, dictionary.start, dictionary.filled, params, 0); + } /* cstream advanced shall write content size = 0 */ + inBuff.src = CNBuffer; + inBuff.size = 0; + inBuff.pos = 0; + outBuff.dst = compressedBuffer; + outBuff.size = compressedBufferSize; + outBuff.pos = 0; + if (ZSTD_isError(ZSTD_compressStream(zc, &outBuff, &inBuff))) goto _output_error; + if (ZSTD_endStream(zc, &outBuff) != 0) goto _output_error; + cSize = outBuff.pos; + if (ZSTD_findDecompressedSize(compressedBuffer, cSize) != 0) goto _output_error; + DISPLAYLEVEL(3, "OK \n"); + DISPLAYLEVEL(3, "test%3i : pledgedSrcSize == 0 behaves properly : ", testNb++); { ZSTD_parameters params = ZSTD_getParams(5, 0, 0); params.fParams.contentSizeFlag = 1;