summaryrefslogtreecommitdiff
path: root/test/inflate-app.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-01-30 09:57:01 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-01-30 09:57:01 +0100
commit917b82955ba8fdbd3c52bb898c01e4f43fc3ca75 (patch)
treecab183063ff57ea80fede9db44882b7082392170 /test/inflate-app.c
parentdb4aac34e9dd6778c132badb7ea000c2684392f9 (diff)
add tests
Diffstat (limited to 'test/inflate-app.c')
-rw-r--r--test/inflate-app.c34
1 files changed, 34 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+
+#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;
+}