Skip to content

Commit

Permalink
Merge pull request #185 from ariel-anieli/ec-talk-test
Browse files Browse the repository at this point in the history
Moved `ec_talk` tests into separate file
  • Loading branch information
ferd authored Sep 24, 2024
2 parents 6d4e7d1 + 5305348 commit 6cd37a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
28 changes: 5 additions & 23 deletions src/ec_talk.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
say/1,
say/2]).

-ifdef(TEST).
-export([get_boolean/1,
get_integer/1]).
-endif.

-export_type([prompt/0,
type/0,
supported/0]).
Expand Down Expand Up @@ -196,26 +201,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 6cd37a4

Please sign in to comment.