summaryrefslogtreecommitdiff
path: root/neozip/test/gh1235.c
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
commit7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch)
treeb43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/test/gh1235.c
parentb1e34e861b5d732afe828d58aad2c638135061fd (diff)
parentc2712b8a345191f6ed79558c089777df94590087 (diff)
downloadProject-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz
Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/test/gh1235.c')
-rw-r--r--neozip/test/gh1235.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/neozip/test/gh1235.c b/neozip/test/gh1235.c
new file mode 100644
index 0000000000..7bf8738f34
--- /dev/null
+++ b/neozip/test/gh1235.c
@@ -0,0 +1,39 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include "zutil.h"
+
+int main(void) {
+ unsigned char plain[32];
+ unsigned char compressed[130];
+ PREFIX3(stream) strm;
+ z_size_t bound;
+ z_size_t bytes;
+
+ for (int i = 0; i <= 32; i++) {
+ memset(plain, 6, i);
+ memset(&strm, 0, sizeof(strm));
+ PREFIX(deflateInit2)(&strm, 0, 8, 31, 1, Z_DEFAULT_STRATEGY);
+ bound = PREFIX(deflateBound)(&strm, i);
+ strm.next_in = plain;
+ strm.next_out = compressed;
+ strm.avail_in = i;
+ strm.avail_out = sizeof(compressed);
+ if (PREFIX(deflate)(&strm, Z_FINISH) != Z_STREAM_END) return -1;
+ if (strm.avail_in != 0) return -1;
+ printf("bytes = %2i, deflateBound = %2zi, total_out = %2zi\n", i, (size_t)bound, (size_t)strm.total_out);
+ if (bound < strm.total_out) return -1;
+ if (PREFIX(deflateEnd)(&strm) != Z_OK) return -1;
+ }
+ for (int i = 0; i <= 32; i++) {
+ bytes = sizeof(compressed);
+ for (int j = 0; j < i; j++) {
+ plain[j] = j;
+ }
+ bound = PREFIX(compressBound)(i);
+ if (PREFIX(compress2)(compressed, &bytes, plain, i, 1) != Z_OK) return -1;
+ printf("bytes = %2i, compressBound = %2zi, total_out = %2zi\n", i, (size_t)bound, (size_t)bytes);
+ if (bytes > bound) return -1;
+ }
+ return 0;
+}