Skip to content

Commit

Permalink
added two new sudoku tests: one for cornered region, one for one logi…
Browse files Browse the repository at this point in the history
…cal jump
  • Loading branch information
tdou25 committed Aug 10, 2024
1 parent bcc89ef commit 3aac4fc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,55 @@ public void staircaseTest() throws InvalidFileFormatException{

}
}
@Test
public void corneredTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/sudoku/rules/LastCellForNumberDirectRule/CorneredRegion", 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(2, 2);

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

}
}

@Test
public void logicJumpTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/sudoku/rules/LastCellForNumberDirectRule/LogicJumpSimple", 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, 1);

cell.setData(i);
board.addModifiedData(cell);
if (i == 8) {
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,20 @@
<?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="8" x="1" y="0"/>
<cell value="1" x="4" y="0"/>
<cell value="2" x="5" y="0"/>
<cell value="3" x="3" y="1"/>
<cell value="4" x="5" y="1"/>
<cell value="5" x="3" y="2"/>
<cell value="6" x="4" y="2"/>
<cell value="8" x="7" y="2"/>
<cell value="9" x="8" y="2"/>
</cells>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>

0 comments on commit 3aac4fc

Please sign in to comment.