fix: add zip_compress functions

This commit is contained in:
EMQ-YangM 2022-04-13 14:13:24 +08:00
parent 116c04560d
commit 1886893fa1
2 changed files with 26 additions and 0 deletions

View File

@ -179,6 +179,11 @@
, unzip/1
]).
%% compressed Funcs
-export([ zip_compress/1
, zip_uncompress/1
]).
%% Data encode and decode
-export([ base64_encode/1
, base64_decode/1
@ -817,6 +822,16 @@ zip(S) when is_binary(S) ->
unzip(S) when is_binary(S) ->
zlib:unzip(S).
%%------------------------------------------------------------------------------
%% zip_compress Funcs
%%------------------------------------------------------------------------------
zip_compress(S) when is_binary(S) ->
zlib:compress(S).
zip_uncompress(S) when is_binary(S) ->
zlib:uncompress(S).
%%------------------------------------------------------------------------------
%% Data encode and decode Funcs
%%------------------------------------------------------------------------------

View File

@ -632,6 +632,17 @@ prop_zip_fun() ->
?FORALL(S, binary(),
S == apply_func(unzip, [apply_func(zip, [S])])).
%%------------------------------------------------------------------------------
%% Test cases for zip funcs
%%------------------------------------------------------------------------------
t_zip_compress_funcs(_) ->
?PROPTEST(prop_zip_compress_fun).
prop_zip_compress_fun() ->
?FORALL(S, binary(),
S == apply_func(zip_uncompress, [apply_func(zip_compress, [S])])).
%%------------------------------------------------------------------------------
%% Test cases for base64
%%------------------------------------------------------------------------------