]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[test] Test the bounds of ZSTD_c_srcSizeHint 1801/head
authorNick Terrell <terrelln@fb.com>
Wed, 18 Sep 2019 18:05:08 +0000 (11:05 -0700)
committerNick Terrell <terrelln@fb.com>
Wed, 18 Sep 2019 18:05:08 +0000 (11:05 -0700)
tests/zstreamtest.c

index 9af08ebe49ba8d788ed58a630bc539dac09f5941..2047d4bd85ccdc66f71d07de13d58ace0f145275 100644 (file)
@@ -1151,6 +1151,16 @@ static int basicUnitTests(U32 seed, double compressibility)
     }
     DISPLAYLEVEL(3, "OK \n");
 
+    DISPLAYLEVEL(3, "test%3i : ZSTD_c_srcSizeHint bounds : ", testNb++);
+    ZSTD_CCtx_reset(zc, ZSTD_reset_session_and_parameters);
+    CHECK_Z(ZSTD_CCtx_setParameter(zc, ZSTD_c_srcSizeHint, INT_MAX));
+    {   int srcSizeHint;
+        CHECK_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_srcSizeHint, &srcSizeHint));
+        CHECK(!(srcSizeHint == INT_MAX), "srcSizeHint doesn't match");
+    }
+    CHECK(!ZSTD_isError(ZSTD_CCtx_setParameter(zc, ZSTD_c_srcSizeHint, -1)), "Out of range doesn't error");
+    DISPLAYLEVEL(3, "OK \n");
+
     /* Overlen overwriting window data bug */
     DISPLAYLEVEL(3, "test%3i : wildcopy doesn't overwrite potential match data : ", testNb++);
     {   /* This test has a window size of 1024 bytes and consists of 3 blocks: