Skip to content

Commit

Permalink
Moved ec_talk tests into separate file
Browse files Browse the repository at this point in the history
Part of erlware#179.

Signed-off-by: Ariel Otilibili <[email protected]>
  • Loading branch information
Ariel Otilibili committed Sep 22, 2024
1 parent 6d4e7d1 commit bbbbb3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
27 changes: 3 additions & 24 deletions src/ec_talk.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
ask_default/3,
ask/3,
say/1,
say/2]).
say/2,
get_boolean/1,
get_integer/1]).

-export_type([prompt/0,
type/0,
Expand Down Expand Up @@ -196,26 +198,3 @@ get_string(String) ->
false ->
no_clue
end.

%%%====================================================================
%%% tests
%%%====================================================================
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

general_test_() ->
[?_test(42 == get_integer("42")),
?_test(500_211 == get_integer("500211")),
?_test(1_234_567_890 == get_integer("1234567890")),
?_test(12_345_678_901_234_567_890 == get_integer("12345678901234567890")),
?_test(true == get_boolean("true")),
?_test(false == get_boolean("false")),
?_test(true == get_boolean("Ok")),
?_test(true == get_boolean("ok")),
?_test(true == get_boolean("Y")),
?_test(true == get_boolean("y")),
?_test(false == get_boolean("False")),
?_test(false == get_boolean("No")),
?_test(false == get_boolean("no"))].

-endif.
19 changes: 19 additions & 0 deletions test/ec_talk_tests.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%%% @copyright 2024 Erlware, LLC.
-module(ec_talk_tests).

-include_lib("eunit/include/eunit.hrl").

general_test_() ->
[?_test(42 == ec_talk:get_integer("42")),
?_test(500_211 == ec_talk:get_integer("500211")),
?_test(1_234_567_890 == ec_talk:get_integer("1234567890")),
?_test(12_345_678_901_234_567_890 == ec_talk:get_integer("12345678901234567890")),
?_test(true == ec_talk:get_boolean("true")),
?_test(false == ec_talk:get_boolean("false")),
?_test(true == ec_talk:get_boolean("Ok")),
?_test(true == ec_talk:get_boolean("ok")),
?_test(true == ec_talk:get_boolean("Y")),
?_test(true == ec_talk:get_boolean("y")),
?_test(false == ec_talk:get_boolean("False")),
?_test(false == ec_talk:get_boolean("No")),
?_test(false == ec_talk:get_boolean("no"))].

0 comments on commit bbbbb3b

Please sign in to comment.