Skip to content

Commit

Permalink
Added new Surround Star direct rule test
Browse files Browse the repository at this point in the history
  • Loading branch information
summerhenson committed Jun 21, 2024
1 parent 109293b commit cd42e83
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,33 @@ public void SurroundStarDirectRule_CenterStarOneTile() throws InvalidFileFormatE
}
}

@Test
public void SurroundStarDirectRule_CenterStarOneTileDiagonal() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar", starbattle);
TreeNode rootNode = starbattle.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

StarBattleBoard board = (StarBattleBoard) transition.getBoard();
StarBattleCell cell = board.getCell(0,0);
cell.setData(StarBattleCellType.BLACK.value);
board.addModifiedData(cell);

Assert.assertNull(RULE.checkRule(transition));

Point location = new Point(0, 0);
for (int i = 0; i < board.getHeight(); i++) {
for (int k = 0; k < board.getWidth(); k++) {
Point point = new Point(k, i);
if (point.equals(location)) {
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
} else {
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
}
}
}

@Test
public void SurroundStarDirectRule_CenterStarAllTiles()
throws InvalidFileFormatException {
Expand Down Expand Up @@ -136,7 +163,7 @@ public void SurroundStarDirectRule_FalseContradiction()
board.addModifiedData(cell);

Assert.assertNotNull(RULE.checkRule(transition));

for (int i = 0; i < board.getHeight(); i++) {
for (int k = 0; k < board.getWidth(); k++) {
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
Expand Down

0 comments on commit cd42e83

Please sign in to comment.