Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

34 рядки
841 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. cases_path("short-doubles.txt").
  8. short_double_test_() ->
  9. {ok, Fd} = file:open(filename(), [read, binary, raw]),
  10. {timeout, 300, ?_assertEqual(0, run(Fd, 0))}.
  11. run(Fd, Acc) ->
  12. case file:read_line(Fd) of
  13. {ok, Data} ->
  14. V1 = re:replace(iolist_to_binary(Data), <<"\.\n">>, <<"">>),
  15. V2 = iolist_to_binary(V1),
  16. V3 = <<34, V2/binary, 34>>,
  17. R = jiffy:encode(jiffy:decode(V3)),
  18. case R == V3 of
  19. true -> run(Fd, Acc);
  20. false -> run(Fd, Acc + 1)
  21. end;
  22. eof ->
  23. Acc
  24. end.