tests/legagy.c: More fixes

dev
Lzu Tao 2019-01-06 23:42:24 +07:00
parent de7e3be7fa
commit 260ff2f6b7
1 changed files with 9 additions and 5 deletions

View File

@ -74,6 +74,7 @@ static int testSimpleAPI(void)
static int testStreamingAPI(void)
{
int error_code = 0;
size_t const outBuffSize = ZSTD_DStreamOutSize();
char* const outBuff = malloc(outBuffSize);
ZSTD_DStream* const stream = ZSTD_createDStream();
@ -97,13 +98,15 @@ static int testStreamingAPI(void)
size_t const ret = ZSTD_initDStream(stream);
if (ZSTD_isError(ret)) {
DISPLAY("ERROR: ZSTD_initDStream: %s\n", ZSTD_getErrorName(ret));
return 1;
error_code = 1;
break;
} }
{ size_t const ret = ZSTD_decompressStream(stream, &output, &input);
if (ZSTD_isError(ret)) {
DISPLAY("ERROR: ZSTD_decompressStream: %s\n", ZSTD_getErrorName(ret));
return 1;
error_code = 1;
break;
}
if (ret == 0) {
@ -112,7 +115,8 @@ static int testStreamingAPI(void)
if (memcmp(outBuff, EXPECTED + outputPos, output.pos) != 0) {
DISPLAY("ERROR: Wrong decoded output produced\n");
return 1;
error_code = 1;
break;
}
outputPos += output.pos;
if (input.pos == input.size && output.pos < output.size) {
@ -122,8 +126,8 @@ static int testStreamingAPI(void)
free(outBuff);
ZSTD_freeDStream(stream);
DISPLAY("Streaming API OK\n");
return 0;
if (error_code == 0) DISPLAY("Streaming API OK\n");
return error_code;
}
int main(void)