Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Testing of built in echo type

  • Loading branch information...
commit 92d682ce5f32bcdf2be743840c1dcddc52a1ae95 1 parent 82cf19f
Gianfranco Alongi authored
Showing with 15 additions and 1 deletion.
  1. +2 −0  Two/Solution/src/port.erl
  2. +13 −1 Two/Solution/test/port_tests.erl
View
2  Two/Solution/src/port.erl
@@ -50,6 +50,8 @@ close(Port) ->
-spec(handle(#port{},string()) -> string()).
+handle(#port{type = echo},Input) ->
+ Input;
handle(Port,Input) ->
Mod = list_to_atom(Port#port.type),
Mod:handle(Input).
View
14 Two/Solution/test/port_tests.erl
@@ -53,7 +53,19 @@ port_handle_test() ->
{ok,Openport} = port:open(FileDir,Port,Type),
Input = "this will be the same",
Result = port:handle(Openport,Input),
- ?assertEqual("this will be the same",Result).
+ ?assertEqual("this will be the same",Result),
+ port:close(Openport).
+
+port_handle_builtin_echo_test() ->
+ Port = 50007,
+ Type = echo,
+ FileDir = "./test/test_files/",
+ {ok,Openport} = port:open(FileDir,Port,Type),
+ Input = "this will be the same",
+ Result = port:handle(Openport,Input),
+ ?assertEqual("this will be the same",Result),
+ port:close(Openport).
+
%% ------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.