Permalink
Browse files

Added negative test of overflow

  • Loading branch information...
1 parent 93d87ec commit 98a2556535fcc25a1c55017113a2b5476a9de88a Gianfranco Alongi committed Feb 19, 2012
Showing with 12 additions and 1 deletion.
  1. +3 −1 One/Solution/src/ros_analyzer.erl
  2. +9 −0 One/Solution/test/ros_analyzer_tests.erl
@@ -7,7 +7,9 @@ analyze(#ros{total = Total,entries = Entries}) ->
Entries_Total = sum_entries(Entries),
case Entries_Total - Total of
X when X < 0 ->
- {error,{underflow,X}}
+ {error,{underflow,X}};
+ X when X > 0 ->
+ {error,{overflow,X}}
end.
sum_entries([]) -> 0;
@@ -10,4 +10,13 @@ analysis_underflow_discrepancy_test() ->
total = 11},
?assertEqual({error,{underflow,-1}},ros_analyzer:analyze(Analysis_input)).
+analysis_overflow_discrepancy_test() ->
+ Entries = [#entry{type = "a",
+ sold = 1,
+ projected = 10}],
+ Analysis_input = #ros{entries = Entries,
+ total = 9},
+ ?assertEqual({error,{overflow,1}},ros_analyzer:analyze(Analysis_input)).
+
+

0 comments on commit 98a2556

Please sign in to comment.