Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

40 строки
1003 B

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. -module(jiffy_10_short_double_tests).
  4. -include_lib("eunit/include/eunit.hrl").
  5. -include("jiffy_util.hrl").
  6. filename() ->
  7. {ok, Cwd} = file:get_cwd(),
  8. case filename:basename(Cwd) of
  9. ".eunit" ->
  10. "../test/cases/short-doubles.txt";
  11. _ ->
  12. "test/cases/short-doubles.txt"
  13. end.
  14. short_double_test_() ->
  15. {ok, Fd} = file:open(filename(), [read, binary, raw]),
  16. {timeout, 300, ?_assertEqual(0, run(Fd, 0))}.
  17. run(Fd, Acc) ->
  18. case file:read_line(Fd) of
  19. {ok, Data} ->
  20. V1 = re:replace(iolist_to_binary(Data), <<"\.\n">>, <<"">>),
  21. V2 = iolist_to_binary(V1),
  22. V3 = <<34, V2/binary, 34>>,
  23. R = jiffy:encode(jiffy:decode(V3)),
  24. case R == V3 of
  25. true -> run(Fd, Acc);
  26. false -> run(Fd, Acc + 1)
  27. end;
  28. eof ->
  29. Acc
  30. end.