Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* command.erl

  Added new close parsing clause

* command.hrl
  Added new possible type 'close' to type field of #port{}

* command_tests.erl
  Added port closing command test
  • Loading branch information...
commit 4a801c628b48f3c1a9c417402056279a1aafe249 1 parent 327cbd8
Gianfranco Alongi authored
View
7 Two/Solution/src/command.erl
@@ -23,7 +23,12 @@ parse("open "++Rest) ->
[Port,Type] = string:tokens(Rest," "),
#port{type = open,
arguments = [{port,list_to_integer(Port)},
- {type,Type}]}.
+ {type,Type}]};
+
+parse("close "++Rest) ->
+ #port{type = close,
+ arguments = [{port,list_to_integer(Rest)}]}.
+
View
2  Two/Solution/src/command.hrl
@@ -2,6 +2,6 @@
arguments :: [{atom(),string()}]
}).
--record(port,{type :: open,
+-record(port,{type :: open | close,
arguments :: [{atom(),string() | non_neg_integer()}]
}).
View
8 Two/Solution/test/command_tests.erl
@@ -29,6 +29,12 @@ open_test() ->
arguments = [{port,1234},
{type,"testtype"}]},
command:parse(Command)).
-
+
+
+close_test() ->
+ Command = "close 1234",
+ ?assertMatch(#port{type = close,
+ arguments = [{port,1234}]},
+ command:parse(Command)).
Please sign in to comment.
Something went wrong with that request. Please try again.