您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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