Список кортежей не совпадает при выполнении тестовых случаев
У меня есть очень простой кусок кода:
-module(tuples_from_file).
-export([parse/0]).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
%%%==================================================================
%%% Export
%%%==================================================================
parse() ->
{ok, File} = file:read_file("assets/tests/input/tuples_from_file.txt"),
%%io:format("File >> ~p~n", [File]),
List = binary:split(File, [<<" ">>, <<"\t">>, <<"\n">>], [global, trim_all]),
%%io:format("List >> ~p~n", [List]),
%%io:format("build_tuples >> ~p~n", [build_tuples(List, [])]),
build_tuples(List, []).
-ifdef(TEST).
parse_test() ->
R1 = [{<<"1">>, <<"7">>}, {<<"11">>, <<"0">>}, {<<"1">>, <<"3">>}, {<<"5">>, <<"0">>}, {<<"7">>, <<"0">>},
{<<"1">>, <<"8">>}, {<<"10">>, <<"0">>}, {<<"1">>, <<"11">>}, {<<"99">>, <<"0">>}],
?assertEqual(R1, tuples_from_file:parse()).
-endif.
%%%==================================================================
%%% Internal
%%%==================================================================
build_tuples([X, Y | T], Acc) -> build_tuples(T, [{X, Y} | Acc]);
build_tuples([X | T], Acc) -> build_tuples(T, [{X, undefined} | Acc]);
build_tuples([], Acc) -> lists:reverse(Acc).
... и это содержание tuples_from_file.txt
:
1 7 11 0
1 3 5 0 7 0
1 8 10 0 1 11
99 0
Когда я запускаю пример (не модульные тесты), я получаю вывод точно такой же, как и при включенном R1
,
Почему assertEqual
всегда терпит неудачу, говоря:
...
in function tuples_from_file:parse/0 (src/unclassified/tuples_from_file.erl, line 20)
in call from tuples_from_file:'-parse_test/0-fun-0-'/1 (src/unclassified/tuples_from_file.erl, line 31)
**error:{badmatch,{error,enoent}}
ERROR: One or more eunit tests failed.
ERROR: eunit failed while processing /Users/vvera/Workshop/Erlang/erlang_contests: rebar_abort
Это структура проекта:
erlang_contests
|-assets
|---tests
|-----input
|-----output
|-doc
|-ebin
|-include
|-priv
|-src
|---leetcode
|-----algorithms
|---unclassified
|-test
|---leetcode
|-----algorithms
|---unclassified