Merge pull request #40 from bb4242/master

Allow packing maps even when {format,map} is not set.
This commit is contained in:
UENISHI Kota 2015-03-11 22:12:19 +09:00
commit b59e14411e
2 changed files with 8 additions and 1 deletions

View File

@ -122,7 +122,7 @@ handle_binary(Bin, Opt) ->
end.
%% %% map interface
handle_ext(Map, Opt = ?OPTION{interface=map}) when is_map(Map) ->
handle_ext(Map, Opt) when is_map(Map) ->
pack_map(maps:to_list(Map), Opt);
handle_ext(Any, _Opt = ?OPTION{ext_packer=Packer,

View File

@ -237,6 +237,13 @@ map_test_()->
?assertEqual(BinaryJSX, Binary)
end},
{"pack map without {format,map}",
fun() ->
Map = maps:from_list([ {X, X * 2} || X <- lists:seq(0, 16) ]),
Binary = pack(Map),
?assertEqual({ok,Map}, unpack(Binary, [{format,map}]))
end},
{"map length 16",
fun() ->
Map = maps:from_list([ {X, X * 2} || X <- lists:seq(0, 16) ]),