-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sudoku' of https://github.com/Bram-Hub/LEGUP into sudoku
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
output_path/test/src/resources/puzzles/sudoku/rules/LastNumberForCellDirectRule/FullRegion
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<Legup version="2.0.0"> | ||
<puzzle name="Sudoku"> | ||
<board size="9"> | ||
<cells> | ||
<cell value="1" x="0" y="3"/> | ||
<cell value="2" x="1" y="3"/> | ||
<cell value="3" x="2" y="3"/> | ||
<cell value="4" x="0" y="4"/> | ||
<cell value="5" x="1" y="4"/> | ||
<cell value="6" x="2" y="4"/> | ||
<cell value="7" x="0" y="5"/> | ||
<cell value="8" x="1" y="5"/> | ||
|
||
</cells> | ||
</board> | ||
</puzzle> | ||
<solved isSolved="false" lastSaved="--"/> | ||
</Legup> |
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
49 changes: 49 additions & 0 deletions
49
src/test/java/puzzles/sudoku/rules/LastNumberForCellDirectRuleRegionTest.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package puzzles.sudoku.rules; | ||
|
||
import edu.rpi.legup.model.tree.TreeNode; | ||
import edu.rpi.legup.model.tree.TreeTransition; | ||
import edu.rpi.legup.puzzle.sudoku.Sudoku; | ||
import edu.rpi.legup.puzzle.sudoku.SudokuBoard; | ||
import edu.rpi.legup.puzzle.sudoku.SudokuCell; | ||
import edu.rpi.legup.puzzle.sudoku.rules.LastNumberForCellDirectRule; | ||
import edu.rpi.legup.save.InvalidFileFormatException; | ||
import legup.MockGameBoardFacade; | ||
import legup.TestUtilities; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
public class LastNumberForCellDirectRuleRegionTest { | ||
private static final LastNumberForCellDirectRule RULE = new LastNumberForCellDirectRule(); | ||
private static Sudoku sudoku; | ||
@BeforeClass | ||
public static void setUp() { | ||
MockGameBoardFacade.getInstance(); | ||
sudoku = new Sudoku(); | ||
} | ||
@Test | ||
public void LastNumberForCellDirectRule_FullRegionTest() throws InvalidFileFormatException { | ||
//Import board and create transition | ||
TestUtilities.importTestBoard("puzzles/sudoku/rules/LastNumberForCellDirectRule/FullRegion", sudoku); | ||
TreeNode rootNode = sudoku.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
for(int i = 1; i < 10; i++){ | ||
//Reset board | ||
SudokuBoard board = (SudokuBoard) transition.getBoard(); | ||
//Set cell | ||
SudokuCell cell1 = board.getCell(2, 5); | ||
cell1.setData(i); | ||
board.addModifiedData(cell1); | ||
|
||
//Test the case | ||
if(i == 9) { | ||
Assert.assertNull(RULE.checkRuleAt(transition, cell1)); | ||
} else { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, cell1)); | ||
} | ||
} | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/resources/puzzles/sudoku/rules/LastNumberForCellDirectRule/FullRegion
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<Legup> | ||
<puzzle name="Sudoku"> | ||
<board size="9"> | ||
<cells> | ||
<cell value="1" x="0" y="3"/> | ||
<cell value="2" x="1" y="3"/> | ||
<cell value="3" x="2" y="3"/> | ||
<cell value="4" x="0" y="4"/> | ||
<cell value="5" x="1" y="4"/> | ||
<cell value="6" x="2" y="4"/> | ||
<cell value="7" x="0" y="5"/> | ||
<cell value="8" x="1" y="5"/> | ||
</cells> | ||
</board> | ||
</puzzle> | ||
<solved isSolved="false" lastSaved="--"/> | ||
</Legup> |