Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bert.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ encode_term(Term) ->
[] -> {bert, nil};
true -> {bert, true};
false -> {bert, false};
Dict when is_record(Term, dict, 8) ->
Dict when is_tuple(Term) andalso element(1, Term) =:= dict ->
{bert, dict, dict:to_list(Dict)};
List when is_list(Term) ->
lists:map((fun encode_term/1), List);
Expand Down
14 changes: 13 additions & 1 deletion test/bert_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ encode_tuple_nesting_test() ->
Bert = term_to_binary({foo, {bert, true}}),
Bert = encode({foo, true}).

encode_dict_test() ->
Bert = term_to_binary({ bert, dict,
dict:to_list(dict:store(foo, true, dict:new())) }),
Bert = encode(dict:store(foo, true, dict:new())).

%% decode

decode_list_nesting_test() ->
Expand All @@ -20,4 +25,11 @@ decode_list_nesting_test() ->
decode_tuple_nesting_test() ->
Bert = term_to_binary({foo, {bert, true}}),
Term = {foo, true},
Term = decode(Bert).
Term = decode(Bert).

decode_dict_test() ->
Bert = term_to_binary({ bert, dict,
dict:to_list(dict:store(foo, true, dict:new())) }),
Term = dict:store(foo, true, dict:new()),
Term = decode(Bert).