1. Shlomi Fish
  2. nurikabe

Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed a0a5f5a

Added another condition.

  • Participants
  • Parent commits d5c6589
  • Branches default

Comments (0)

Files changed (2)

File nurikabe-solver/t/verdict-matrix-tests.py.t

View file
 from TAP.Simple import *
 from ctypes import *
 
-plan(7)
+plan(8)
 
 NK_SOLVE_ERROR__SUCCESS = 0
 NK_SOLVE_ERROR__ALLOC_FAILED = 1
 
     # TEST
     eq_ok (
+            m.set(0,5, NK_SOLVE_VERDICT__BLACK),
+            NK_SOLVE_ERROR__X_OUT_OF_BOUNDS,
+            "X is out of bounds",
+        )
+
+    # TEST
+    eq_ok (
             m.free(),
             NK_SOLVE_ERROR__SUCCESS,
             "nk_solve_verdict_matrix_free was successful"

File nurikabe-solver/verdict_mat.c

View file
     {
         return NK_SOLVE_ERROR__Y_OUT_OF_BOUNDS;
     }
+    
+    if ( ! ((x >= 0) && (x < board->width)) )
+    {
+        return NK_SOLVE_ERROR__X_OUT_OF_BOUNDS;
+    }
 
     return NK_SOLVE_ERROR__ALLOC_FAILED;
 }