Skip to content

Commit

Permalink
Add proper and port gzip property test from Hex
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Mar 3, 2018
1 parent 266bbf2 commit 3454ca1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ language: erlang
sudo: false
otp_release:
- 20.2
script:
- rebar3 eunit
- rebar3 proper
8 changes: 7 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
{erl_opts, [debug_info]}.
{deps, []}.
{plugins, [rebar3_proper]}.
{deps, []}.
{profiles,
[{test, [
{deps, [{proper, "1.2.0"}, recon]}
]}
]}.
1 change: 1 addition & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
16 changes: 16 additions & 0 deletions test/prop_hex_tarball.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-module(prop_hex_tarball).
-include_lib("proper/include/proper.hrl").

prop_symmetric() ->
?FORALL(Binary, binary(),
begin
zlib:gunzip(hex_tarball:gzip(Binary)) =:= Binary
end).

prop_equivalent() ->
?FORALL(Binary, binary(),
begin
<<31, 139, 8, 0, 0, 0, 0, 0, 0, _Os, ZlibRest/binary>> = zlib:gzip(Binary),
<<31, 139, 8, 0, 0, 0, 0, 0, 0, 0, HexRest/binary>> = hex_tarball:gzip(Binary),
ZlibRest =:= HexRest
end).

0 comments on commit 3454ca1

Please sign in to comment.