Permalink
Browse files

Added new negative test for ros_engine and modified failing test for

ros_reader
  • Loading branch information...
Gianfranco Alongi
Gianfranco Alongi committed Feb 19, 2012
1 parent 83b5a81 commit d5822dbe00e0d9ee258c1e528f39813bed3a2c9e
@@ -1,16 +1,18 @@
-module(ros_engine).
-export([run_dir/1]).
--spec(run_dir(string()) -> [{string(),ok}]).
+-spec(run_dir(string()) -> [{string(),ok} | {error,no_total}]).
run_dir(Dir) ->
case ros_reader:read_dir(Dir) of
{ok,Files_Content} ->
work_on_files(Files_Content)
end.
-
+
work_on_files([]) -> [];
work_on_files([{File,Contains}|Rest]) ->
case ros_parser:parse(binary_to_list(Contains)) of
{ok,Ros} ->
- [{File,ros_analyzer:analyze(Ros)} | work_on_files(Rest)]
+ [{File,ros_analyzer:analyze(Ros)} | work_on_files(Rest)];
+ {error,_} = Err ->
+ [{File,Err} | work_on_files(Rest)]
end.
@@ -10,3 +10,10 @@ ros_engine_ok_test() ->
{"january-north_branch-2011.ros",ok},
{"january-south_branch-2011.ros",ok}],Res).
+ros_engine_negative_test() ->
+ Dir = "test/ros_files/",
+ Res = ros_engine:run_dir(Dir),
+ ?assertEqual(
+ [{"file_a.ros",{error,no_total}},
+ {"file_b.ros",{error,no_total}}],Res).
+
@@ -3,7 +3,7 @@
ros_reads_file_test() ->
File = "./test/january-good-2011.ros",
- ?assertMatch({ok,Result},ros_reader:read_file(File)).
+ ?assertEqual(<<>>,ros_reader:read_file(File)).
ros_read_bad_file_test() ->
File = "./test/nonexistent.ros",

0 comments on commit d5822db

Please sign in to comment.