Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudoku #846

Merged
merged 6 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading