Commits

shl...@27f4d2be-69b7-b1af-7dc8-71755b09f50e  committed 2f406c6

Now raising the WrongRowLenException, and properly testing for it.

  • Participants
  • Parent commits 8b1ecca

Comments (0)

Files changed (2)

File hitori-solver-in-ruby/hitori-solver.rb

 class HitoriSolver
+    class WrongRowLenException < RuntimeError
+    end
 
     class Cell
         $UNKNOWN = 0
                     d_row << Cell.new(v)
                 end
                 if (d_row.length() != @x_len)
-                    raise "d_row in pos #{board.length()} has the wrong length"
+                    raise WrongRowLenException, "Wrong number of values in row #{board.length()}."
                 end
                 board << d_row
             end

File hitori-solver-in-ruby/t/parse-board.rb

         board.cell_yx(0,2).value.should == 3
         board.cell_yx(4,2).value.should == 1
     end
+    it "should throw an exception for invalid x_len" do
+        board = 0
+        lambda {
+            board = HitoriSolver::Board.new(2, 4, [[3,2,1],[4,5,6,7]])   
+        }.should raise_error(HitoriSolver::WrongRowLenException)
+    end
 end