Skip to content

Commit

Permalink
Merge pull request #846 from tdou25/sudoku
Browse files Browse the repository at this point in the history
Sudoku
  • Loading branch information
tdou25 authored Aug 6, 2024
2 parents 48ff4b1 + bcc89ef commit 8d53b40
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,60 @@ public static void setUp() {
MockGameBoardFacade.getInstance();
sudoku = new Sudoku();
}
/*test ideas:
-basic test (based off icon)
-"staircase" test
-no possible test
-almost but not actually test
*/
@Test
public void basicSpotTest() throws InvalidFileFormatException{
TestUtilities.importTestBoard(
"puzzles/sudoku/rules/LastCellForNumberDirectRule/OnePossible", sudoku
);
TreeNode rootNode = sudoku.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

for(int i = 1; i <= 9; ++i) {
SudokuBoard board = (SudokuBoard) transition.getBoard();
SudokuCell cell = board.getCell(1,1);

cell.setData(i);
board.addModifiedData(cell);
if(i == 5) {
Assert.assertNull(RULE.checkRuleAt(transition, cell));
}
else {
Assert.assertNotNull(RULE.checkRuleAt(transition, cell));
}

}

}
@Test
public void staircaseTest() throws InvalidFileFormatException{
TestUtilities.importTestBoard(
"puzzles/sudoku/rules/LastCellForNumberDirectRule/StaircaseCase", sudoku
);
TreeNode rootNode = sudoku.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

for(int i = 1; i <= 9; ++i) {
SudokuBoard board = (SudokuBoard) transition.getBoard();
SudokuCell cell = board.getCell(4,4);

cell.setData(i);
board.addModifiedData(cell);
if(i == 7) {
Assert.assertNull(RULE.checkRuleAt(transition, cell));
}
else {
Assert.assertNotNull(RULE.checkRuleAt(transition, cell));
}

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Legup>
<puzzle name="Sudoku">
<board size="9">
<cells>
<cell value="1" x="0" y="0"/>
<cell value="2" x="1" y="0"/>
<cell value="3" x="2" y="0"/>
<cell value="4" x="0" y="1"/>
<cell value="6" x="2" y="1"/>
<cell value="7" x="0" y="2"/>
<cell value="8" x="1" y="2"/>
<cell value="9" x="2" y="2"/>

<cell value="1" x="1" y="3"/>
<cell value="3" x="1" y="4"/>
<cell value="4" x="1" y="5"/>
<cell value="6" x="1" y="6"/>
<cell value="7" x="1" y="7"/>
<cell value="9" x="1" y="8"/>
</cells>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Legup>
<puzzle name="Sudoku">
<board size="9">
<cells>
<cell value="7" x="0" y="0"/>
<cell value="7" x="1" y="3"/>
<cell value="7" x="2" y="6"/>
<cell value="7" x="3" y="1"/>
<cell value="7" x="5" y="7"/>
<cell value="7" x="6" y="2"/>
<cell value="7" x="7" y="5"/>
<cell value="7" x="8" y="8"/>
</cells>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>

0 comments on commit 8d53b40

Please sign in to comment.