Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

44 řádky
1.1 KiB

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