mirror of
https://github.com/facebook/zstd.git
synced 2025-10-07 00:12:40 -04:00
seekable_format no header when compressing empty string to stream
This commit is contained in:
parent
4bba97b4cb
commit
f17652931c
@ -186,6 +186,36 @@ int main(int argc, const char** argv)
|
|||||||
}
|
}
|
||||||
printf("Success!\n");
|
printf("Success!\n");
|
||||||
|
|
||||||
|
|
||||||
|
printf("Test %u - check ZSTD magic in compressing empty string: ", testNb++);
|
||||||
|
{ // compressing empty string should return a zstd header
|
||||||
|
char *data_in = (char *) malloc(255 * sizeof(char));
|
||||||
|
assert(data_in != NULL);
|
||||||
|
data_in = "\0";
|
||||||
|
|
||||||
|
char *data_out = (char *) malloc(255 * 255 * sizeof(char));
|
||||||
|
assert(data_out != NULL);
|
||||||
|
|
||||||
|
ZSTD_seekable_CStream *s = ZSTD_seekable_createCStream();
|
||||||
|
ZSTD_seekable_initCStream(s, 1, 1, 1024 * 1024);
|
||||||
|
|
||||||
|
ZSTD_inBuffer input = { data_in, 0, 0 };
|
||||||
|
ZSTD_outBuffer output = { data_out, 255*255, 0 };
|
||||||
|
|
||||||
|
ZSTD_seekable_compressStream(s, &output, &input);
|
||||||
|
ZSTD_seekable_endStream(s, &output);
|
||||||
|
|
||||||
|
if((((char*)output.dst)[0] != '\x28') | (((char*)output.dst)[1] != '\xb5') | (((char*)output.dst)[2] != '\x2f') | (((char*)output.dst)[3] != '\xfd')) {
|
||||||
|
printf("%#02x %#02x %#02x %#02x\n", ((char*)output.dst)[0], ((char*)output.dst)[1] , ((char*)output.dst)[2] , ((char*)output.dst)[3] );
|
||||||
|
|
||||||
|
ZSTD_seekable_freeCStream(s);
|
||||||
|
goto _test_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZSTD_seekable_freeCStream(s);
|
||||||
|
}
|
||||||
|
printf("Success!\n");
|
||||||
|
|
||||||
/* TODO: Add more tests */
|
/* TODO: Add more tests */
|
||||||
printf("Finished tests\n");
|
printf("Finished tests\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -350,7 +350,7 @@ size_t ZSTD_seekable_writeSeekTable(ZSTD_frameLog* fl, ZSTD_outBuffer* output)
|
|||||||
|
|
||||||
size_t ZSTD_seekable_endStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output)
|
size_t ZSTD_seekable_endStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output)
|
||||||
{
|
{
|
||||||
if (!zcs->writingSeekTable && zcs->frameDSize) {
|
if (!zcs->writingSeekTable) {
|
||||||
const size_t endFrame = ZSTD_seekable_endFrame(zcs, output);
|
const size_t endFrame = ZSTD_seekable_endFrame(zcs, output);
|
||||||
if (ZSTD_isError(endFrame)) return endFrame;
|
if (ZSTD_isError(endFrame)) return endFrame;
|
||||||
/* return an accurate size hint */
|
/* return an accurate size hint */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user