diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-01-30 09:57:01 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-01-30 09:57:01 +0100 |
commit | 917b82955ba8fdbd3c52bb898c01e4f43fc3ca75 (patch) | |
tree | cab183063ff57ea80fede9db44882b7082392170 /test/deflate | |
parent | db4aac34e9dd6778c132badb7ea000c2684392f9 (diff) |
add tests
Diffstat (limited to 'test/deflate')
-rwxr-xr-x | test/deflate | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/deflate b/test/deflate new file mode 100755 index 0000000..0271d59 --- /dev/null +++ b/test/deflate @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys +import zlib + +level = -1 +if len(sys.argv) > 2: + level = int(sys.argv[2]) + +try: + with open(sys.argv[1], "rb") as f: + input_data = f.read() +except FileNotFoundError: + input_data = sys.argv[1].encode("utf-8") + +output = zlib.compress(input_data, level=level) + +sys.stdout.buffer.write(output) |