-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12f68b0
commit b400c25
Showing
6 changed files
with
166 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/test/java/com/github/viktigpetterr/sudokusolver/javafx/AppTest.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/test/java/com/github/viktigpetterr/sudokusolver/javafx/OneNumberTextFieldTest.java
This file was deleted.
Oops, something went wrong.
94 changes: 91 additions & 3 deletions
94
src/test/java/com/github/viktigpetterr/sudokusolver/sudoku/SudokuTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,96 @@ | ||
package com.github.viktigpetterr.sudokusolver.sudoku; | ||
|
||
import org.junit.Test; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class SudokuTest | ||
{ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class SudokuTest { | ||
|
||
private Sudoku sudoku; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
sudoku = new Sudoku(); | ||
} | ||
|
||
@Test | ||
public void testSize() { | ||
assertEquals(9, sudoku.dimension()); | ||
} | ||
|
||
@Test | ||
public void testGetValueOf() { | ||
int row = 0; | ||
int col = 0; | ||
int val = 1; | ||
|
||
sudoku.setValue(row, col, val); | ||
assertEquals(Integer.toString(val), sudoku.getValueOf(col, row)); | ||
} | ||
|
||
@Test | ||
public void testClear() { | ||
int row = 0; | ||
int col = 0; | ||
int val = 1; | ||
|
||
sudoku.setValue(row, col, val); | ||
assertEquals(Integer.toString(val), sudoku.getValueOf(col, row)); | ||
|
||
sudoku.clear(); | ||
int dimension = sudoku.dimension(); | ||
for (col = 0; col < dimension; col++) { | ||
for (row = 0; row < dimension; row++) { | ||
assertEquals(Integer.toString(0), sudoku.getValueOf(row, col)); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testNumIsLegal() { | ||
int row = 0; | ||
int col = 0; | ||
|
||
sudoku.setValue(row, col, 1); | ||
sudoku.setValue(row, sudoku.dimension() - 1, 1); | ||
assertFalse(sudoku.numIsLegal(row, col, 1)); | ||
|
||
sudoku.setValue(row, sudoku.dimension() - 1, 0); | ||
sudoku.setValue(sudoku.dimension() - 1, col, 1); | ||
assertFalse(sudoku.numIsLegal(row, col, 1)); | ||
|
||
sudoku.setValue(sudoku.dimension() - 1, col, 0); | ||
sudoku.setValue(row, col, 1); | ||
assertFalse(sudoku.numIsLegal(row, col, 1)); | ||
|
||
assertTrue(sudoku.numIsLegal(row, col , 2)); | ||
} | ||
|
||
@Test | ||
public void testCheckSudoku() { | ||
int row = 0; | ||
int col = 0; | ||
|
||
sudoku.setValue(row, col, 1); | ||
sudoku.setValue(row, sudoku.dimension() - 1, 1); | ||
assertFalse(sudoku.checkSudoku()); | ||
} | ||
|
||
@Test | ||
public void testSolve() { | ||
int row = 0; | ||
int col = 0; | ||
|
||
sudoku.setValue(row, col, 1); | ||
assertTrue(sudoku.solve()); | ||
|
||
sudoku.clear(); | ||
sudoku.setValue(row, col, 1); | ||
sudoku.setValue(row, sudoku.dimension() - 1, 1); | ||
assertFalse(sudoku.solve()); | ||
} | ||
|
||
} |