Add a simple test in geef_oid

This commit is contained in:
Carlos Martín Nieto
2013-03-01 01:07:49 +01:00
parent 4c798629dd
commit 2c7a984af0
2 changed files with 18 additions and 0 deletions

View File

@@ -13,3 +13,6 @@ compile: $(REBAR)
clean: $(REBAR)
@$(REBAR) clean
test: $(REBAR)
@$(REBAR) eunit

View File

@@ -1,6 +1,11 @@
-module(geef_oid).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
-include("geef_records.hrl").
-export([parse/1, fmt/1]).
-spec fmt(oid()) -> binary().
@@ -12,3 +17,13 @@ fmt(#oid{oid=Oid}) ->
parse(Sha) ->
Oid = geef:oid_parse(Sha),
#oid{oid=Oid}.
-ifdef(TEST).
back_and_forth_test() ->
?assertMatch(<<"d71c6ff702e75247ce29c51279d78a7a202f5cc9">>,
fmt(parse(<<"d71c6ff702e75247ce29c51279d78a7a202f5cc9">>))),
?assertMatch(<<"d71c6ff702e75247ce29c51279d78a7a202f5cc9">>,
fmt(parse("d71c6ff702e75247ce29c51279d78a7a202f5cc9"))).
-endif.