Skip to content

Commit 301d76c

Browse files
committed
More tests
1 parent fd3459c commit 301d76c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

sudoku/src/test/java/de/sfuhrm/sudoku/GameMatrixImplTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,42 @@ public void testFindLeastFreeCell() {
965965
assertEquals(2, min.row);
966966
assertEquals(2, min.column);
967967
}
968+
969+
@Test
970+
public void testFindLeastFreeCellWithNoPossibleValue() {
971+
// (0,0) is empty
972+
// Row 0 has 1, 2, 3, 4, 5, 6, 7, 8
973+
// Col 0 has 9
974+
// Block 0 has 1, 2, 9
975+
// (0,0) sees 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 0 possibilities
976+
byte[][] data =
977+
QuadraticArrays.parse(
978+
"012345678",
979+
"900000000",
980+
"000000000",
981+
"000000000",
982+
"000000000",
983+
"000000000",
984+
"000000000",
985+
"000000000",
986+
"000000000"
987+
);
988+
989+
GameMatrixImpl matrix = new GameMatrixImpl(schema);
990+
matrix.setAll(data);
991+
992+
CellIndex min = new CellIndex();
993+
GameMatrixImpl.FreeCellResult result = matrix.findLeastFreeCell(min);
994+
assertEquals(GameMatrixImpl.FreeCellResult.CONTRADICTION, result);
995+
}
996+
997+
@Test
998+
public void testFindLeastFreeCellWithEmptyMatrix() {
999+
GameMatrixImpl matrix = new GameMatrixImpl(schema);
1000+
CellIndex min = new CellIndex();
1001+
GameMatrixImpl.FreeCellResult result = matrix.findLeastFreeCell(min);
1002+
assertEquals(GameMatrixImpl.FreeCellResult.FOUND, result);
1003+
assertEquals(0, min.row);
1004+
assertEquals(0, min.column);
1005+
}
9681006
}

0 commit comments

Comments
 (0)