Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

42 linhas
991 B

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