]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Added a secondary test, checking dictID presence after setting noDictIdFLag=1 678/head
authorYann Collet <cyan@fb.com>
Thu, 27 Apr 2017 22:08:56 +0000 (15:08 -0700)
committerYann Collet <cyan@fb.com>
Thu, 27 Apr 2017 22:08:56 +0000 (15:08 -0700)
lib/zstd.h
tests/zstreamtest.c

index 3852b720012e64476b3eb817ab145c15b48af143..9a50f23cde04d76dcfd69cf6619ac5a38aff4b22 100644 (file)
@@ -586,7 +586,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
  *    Note : this use case also happens when using a non-conformant dictionary.
  *  - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
  *  - This is not a Zstandard frame.
- *  When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */
+ *  When identifying the exact failure cause, it's possible to use ZSTD_getFrameParams(), which will provide a more precise error code. */
 ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
 
 
index 6d9694e454f3509a541d76d0caa3040d32416d3d..0e09e185642be60d27d7b003265284f6f24b82df 100644 (file)
@@ -451,7 +451,7 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
     DISPLAYLEVEL(3, "test%3i : ZSTD_initCStream_usingCDict_advanced with masked dictID : ", testNb++);
     {   ZSTD_compressionParameters const cParams = ZSTD_getCParams(1, CNBufferSize, dictionary.filled);
         ZSTD_frameParameters const fParams = { 1 /* contentSize */, 1 /* checksum */, 1 /* noDictID */};
-        ZSTD_CDict* const cdict = ZSTD_createCDict_advanced(dictionary.start, dictionary.filled, 1, cParams, customMem);
+        ZSTD_CDict* const cdict = ZSTD_createCDict_advanced(dictionary.start, dictionary.filled, 1 /* byReference */, cParams, customMem);
         size_t const initError = ZSTD_initCStream_usingCDict_advanced(zc, cdict, CNBufferSize, fParams);
         if (ZSTD_isError(initError)) goto _output_error;
         cSize = 0;
@@ -471,6 +471,12 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
         DISPLAYLEVEL(3, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/CNBufferSize*100);
     }
 
+    DISPLAYLEVEL(3, "test%3i : try retrieving dictID from frame : ", testNb++);
+    {   U32 const did = ZSTD_getDictID_fromFrame(compressedBuffer, cSize);
+        if (did != 0) goto _output_error;
+    }
+    DISPLAYLEVEL(3, "OK (not detected) \n");
+
     DISPLAYLEVEL(3, "test%3i : decompress without dictionary : ", testNb++);
     {   size_t const r = ZSTD_decompress(decodedBuffer, CNBufferSize, compressedBuffer, cSize);
         if (!ZSTD_isError(r)) goto _output_error;  /* must fail : dictionary not used */