]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Merge branch 'extract_sequences_api' of https://github.com/bimbashrestha/zstd into...
authorBimba Shrestha <bimbashrestha@fb.com>
Mon, 16 Sep 2019 20:35:49 +0000 (13:35 -0700)
committerBimba Shrestha <bimbashrestha@fb.com>
Mon, 16 Sep 2019 20:35:49 +0000 (13:35 -0700)
1  2 
tests/fuzzer.c

diff --cc tests/fuzzer.c
index b11a3cc06847948a3aecd83990223bd02a2433f5,c0c6b7a1472ac0ecf4c23f9d68253a8d17ebd791..62263fd1dc2a79624046d57a5e6584c2fa90811f
@@@ -1960,16 -1960,23 +1960,28 @@@ static int basicUnitTests(U32 const see
          DISPLAYLEVEL(3, "OK \n");
      }
  
 -    DISPLAYLEVEL(3, "test%3i : ZSTD_getSequences zeros : ", testNb++);
 -    memset(CNBuffer, 0, 1000000);
 -    assert(ZSTD_getSequences(ZSTD_createCCtx(), compressedBuffer, 1000000,
 -        CNBuffer, 1000000) == 1000000 / 131071 + 1);
 +    {
 +        ZSTD_CCtx* cctx = ZSTD_createCCtx();
 +        assert(cctx != NULL);
 +        DISPLAYLEVEL(3, "test%3i : ZSTD_getSequences zeros : ", testNb++);
 +        memset(CNBuffer, 0, 1000000);
 +        assert(ZSTD_getSequences(cctx, compressedBuffer, 1000000,
 +            CNBuffer, 1000000) == 1000000 / 131071 + 1);
 +        ZSTD_freeCCtx(cctx);
 +    }
  
+     /* Multiple blocks of zeros test */
+     #define LONGZEROSLENGTH 1000000 /* 1MB of zeros */
+     DISPLAYLEVEL(3, "test%3i : compress %u zeroes : ", testNb++, LONGZEROSLENGTH);
+     memset(CNBuffer, 0, LONGZEROSLENGTH);
+     CHECK_VAR(cSize, ZSTD_compress(compressedBuffer, ZSTD_compressBound(LONGZEROSLENGTH), CNBuffer, LONGZEROSLENGTH, 1) );
+     DISPLAYLEVEL(3, "OK (%u bytes : %.2f%%)\n", (unsigned)cSize, (double)cSize/LONGZEROSLENGTH*100);
+     DISPLAYLEVEL(3, "test%3i : decompress %u zeroes : ", testNb++, LONGZEROSLENGTH);
+     { CHECK_NEWV(r, ZSTD_decompress(decodedBuffer, LONGZEROSLENGTH, compressedBuffer, cSize) );
+       if (r != LONGZEROSLENGTH) goto _output_error; }
+     DISPLAYLEVEL(3, "OK \n");
      /* All zeroes test (test bug #137) */
      #define ZEROESLENGTH 100
      DISPLAYLEVEL(3, "test%3i : compress %u zeroes : ", testNb++, ZEROESLENGTH);