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;
|
this.board = board;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* <p>
|
||||||
|
* Note that this returns a copy of the board, not the actual board
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int[][] getBoard() {
|
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 */
|
/** Resets the board to all zeros */
|
||||||
|
@ -34,7 +42,6 @@ public class Solver implements SudokuSolver {
|
||||||
row[i] = 0;
|
row[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// board = new int[9][9];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {@inheritDoc} */
|
/* {@inheritDoc} */
|
||||||
|
|
|
@ -17,8 +17,12 @@ class SolverTest {
|
||||||
Solver solver = new Solver();
|
Solver solver = new Solver();
|
||||||
int[][] board = new int[9][9];
|
int[][] board = new int[9][9];
|
||||||
solver.setBoard(board);
|
solver.setBoard(board);
|
||||||
assertEquals(board, solver.getBoard());
|
|
||||||
|
for (int row = 0; row < 9; row++) {
|
||||||
|
assertArrayEquals(board[row], solver.getBoard()[row]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void randomizeBoardTest() {
|
void randomizeBoardTest() {
|
||||||
|
@ -28,6 +32,12 @@ class SolverTest {
|
||||||
assertNotEquals(board, solver.getBoard());
|
assertNotEquals(board, solver.getBoard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void emptyTest() {
|
||||||
|
Solver solver = new Solver();
|
||||||
|
assertTrue(solver.solve());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void legalTest() {
|
void legalTest() {
|
||||||
Solver solver = new Solver();
|
Solver solver = new Solver();
|
||||||
|
|
Loading…
Reference in a new issue