Commits

Anonymous committed 128cef8

Added a test and uncovered a (now fixed) bug with the board parsing.

Comments (0)

Files changed (2)

solver/ruby/kakuro-board.rb

             # TODO : Make sure the widths of all the lines are the same.
             width = 0
             row = []
-            while line.sub!(/\A\s*\[([^\]]+)\]\s*/, "")
+            while line.sub!(/\A\s*\[([^\]]*)\]\s*/, "")
                 content = $1
 
                 cell = Cell.new(_next_cell_id(), content)
                 row << cell.id
             end
             @width = width
-            @matrix << row
+            @matrix.push(row)
         end
 
         def cell_yx(row,col)

solver/ruby/t/parse-board.rb

 EOF
     end
 
-    it "cell(0,0) is block" do
+    it "cells in 0th row are solid or not" do
         @board.cell_yx(0,0).solid?.should
+        @board.cell_yx(0,1).solid?.should
+        @board.cell_yx(0,2).solid?.should
+    end
+
+    it "cells in 1st row are solid or not" do
+        @board.cell_yx(1,2).solid?.should_not
     end
 end