Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* command.erl

  New clause for parsing open port type command

* command.hrl
  New record type #open{}

* command_tests.erl
  New test for open command
  • Loading branch information...
commit d26c27696d0f6cfd5c543c5a154e82a109255428 1 parent 167aa41
Gianfranco Alongi authored
8 Two/Solution/src/command.erl
View
@@ -17,7 +17,13 @@ parse("bind "++Rest) ->
parse("unbind "++Type) ->
#binding{type = unbind,
- arguments = [{type,Type}]}.
+ arguments = [{type,Type}]};
+
+parse("open "++Rest) ->
+ [Port,Type] = string:tokens(Rest," "),
+ #open{port = list_to_integer(Port),
+ type = Type}.
+
4 Two/Solution/src/command.hrl
View
@@ -1,3 +1,7 @@
-record(binding,{type :: list | bind | unbind,
arguments :: [{atom(),string()}]
}).
+
+-record(open,{port :: non_neg_integer(),
+ type :: string()
+ }).
7 Two/Solution/test/command_tests.erl
View
@@ -22,5 +22,12 @@ unbind_test() ->
?assertMatch(#binding{type = unbind,
arguments = [{type,"testtype"}]},
command:parse(Command)).
+
+open_test() ->
+ Command = "open 1234 testtype",
+ ?assertMatch(#open{port = 1234,
+ type = "testtype"},
+ command:parse(Command)).
+
Please sign in to comment.
Something went wrong with that request. Please try again.