您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

47 行
1.1 KiB

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. -compile(export_all).
  4. -compile(nowarn_export_all).
  5. msg(Fmt, Args) ->
  6. M1 = io_lib:format(Fmt, Args),
  7. M2 = re:replace(M1, <<"\r">>, <<"\\\\r">>, [global]),
  8. M3 = re:replace(M2, <<"\n">>, <<"\\\\n">>, [global]),
  9. M4 = re:replace(M3, <<"\t">>, <<"\\\\t">>, [global]),
  10. iolist_to_binary(M4).
  11. hex(Bin) when is_binary(Bin) ->
  12. H1 = [io_lib:format("16#~2.16.0B",[X]) || <<X:8>> <= Bin],
  13. H2 = string:join(H1, ", "),
  14. lists:flatten(io_lib:format("<<~s>>", [lists:flatten(H2)])).
  15. dec(V) ->
  16. jiffy:decode(V).
  17. dec(V, Opts) ->
  18. jiffy:decode(V, Opts).
  19. enc(V) ->
  20. iolist_to_binary(jiffy:encode(V)).
  21. enc(V, Opts) ->
  22. iolist_to_binary(jiffy:encode(V, Opts)).
  23. %% rebar runs eunit with PWD as .eunit/
  24. %% rebar3 runs eunit with PWD as ./
  25. %% this adapts to the differences
  26. cases_path(Suffix) ->
  27. {ok, Cwd} = file:get_cwd(),
  28. Prefix = case filename:basename(Cwd) of
  29. ".eunit" -> "..";
  30. _ -> "."
  31. end,
  32. Path = "test/cases",
  33. filename:join([Prefix, Path, Suffix]).