Making sure application is up to spec
This commit is contained in:
parent
ffd1d4bd51
commit
7eab9da318
2 changed files with 23 additions and 6 deletions
|
@ -20,10 +20,18 @@ public class Solver implements SudokuSolver {
|
|||
this.board = board;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Note that this returns a copy of the board, not the actual board
|
||||
*/
|
||||
@Override
|
||||
public int[][] getBoard() {
|
||||
return board;
|
||||
int[][] copy = new int[9][9];
|
||||
for (int row = 0; row < 9; row++) {
|
||||
System.arraycopy(board[row], 0, copy[row], 0, 9);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/** Resets the board to all zeros */
|
||||
|
@ -34,7 +42,6 @@ public class Solver implements SudokuSolver {
|
|||
row[i] = 0;
|
||||
}
|
||||
}
|
||||
// board = new int[9][9];
|
||||
}
|
||||
|
||||
/* {@inheritDoc} */
|
||||
|
|
|
@ -17,8 +17,12 @@ class SolverTest {
|
|||
Solver solver = new Solver();
|
||||
int[][] board = new int[9][9];
|
||||
solver.setBoard(board);
|
||||
assertEquals(board, solver.getBoard());
|
||||
|
||||
for (int row = 0; row < 9; row++) {
|
||||
assertArrayEquals(board[row], solver.getBoard()[row]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void randomizeBoardTest() {
|
||||
|
@ -28,6 +32,12 @@ class SolverTest {
|
|||
assertNotEquals(board, solver.getBoard());
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyTest() {
|
||||
Solver solver = new Solver();
|
||||
assertTrue(solver.solve());
|
||||
}
|
||||
|
||||
@Test
|
||||
void legalTest() {
|
||||
Solver solver = new Solver();
|
||||
|
|
Loading…
Reference in a new issue