Skip to content

Commit

Permalink
Add a simple eunit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagabond committed Aug 28, 2018
1 parent 214943b commit d2a8fdb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/erasure.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,19 @@ init() ->

not_loaded(Line) ->
erlang:nif_error({not_loaded, [{module, ?MODULE}, {line, Line}]}).


-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

simple_test() ->
Data = <<"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec nisi interdum, ultricies mauris eget, congue ante. Fusce erat diam, lacinia eu volutpat ut, gravida quis justo. Maecenas sagittis, ligula.">>,
{ok, Shards} = encode(5, 2, Data),
?assertEqual({ok, Data}, decode(5, 2, Shards)),
?assertEqual({ok, Data}, decode(5, 2, lists:sublist(Shards, 5))),
?assertEqual({ok, Data}, decode(5, 2, lists:reverse(lists:sublist(Shards, 5)))),
?assertMatch({error, _}, decode(5, 2, lists:sublist(Shards, 4))),
?assertMatch({error, _}, decode(5, 2, lists:sublist(Shards, 4) ++ [hd(Shards)])),
ok.

-endif.

0 comments on commit d2a8fdb

Please sign in to comment.