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.

39 linhas
895 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. enc(V) ->
  15. iolist_to_binary(jiffy:encode(V)).
  16. enc(V, Opts) ->
  17. iolist_to_binary(jiffy:encode(V, Opts)).
  18. %% rebar runs eunit with PWD as .eunit/
  19. %% rebar3 runs eunit with PWD as ./
  20. %% this adapts to the differences
  21. cases_path() ->
  22. Path = "test/cases",
  23. AltPath = "../" ++ Path,
  24. case filelib:is_dir( Path ) of
  25. true -> Path;
  26. false -> AltPath
  27. end.