From 917b82955ba8fdbd3c52bb898c01e4f43fc3ca75 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 30 Jan 2021 09:57:01 +0100 Subject: add tests --- test/inflate-app.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/inflate-app.c (limited to 'test/inflate-app.c') diff --git a/test/inflate-app.c b/test/inflate-app.c new file mode 100644 index 0000000..dddc807 --- /dev/null +++ b/test/inflate-app.c @@ -0,0 +1,34 @@ +#include +#include + +#include "inflate.h" + +unsigned char *inbuf; +unsigned char *outbuf; + +int main(void) +{ + // 16 MB + inbuf = malloc(4096 * 4096); + outbuf = malloc(4096 * 4096); + + if (inbuf == NULL || outbuf == NULL) { + return 1; + } + + size_t in_size = fread(inbuf, 1, 4096 * 4096, stdin); + + if (in_size == 0) { + return 1; + } + + int16_t out_size = inflate_zlib(inbuf, in_size, outbuf, 65535); + + if (out_size < 0) { + return -out_size; + } + + fwrite(outbuf, 1, out_size, stdout); + + return 0; +} -- cgit v1.2.3