diff --git a/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java index ae7621b31..f6894d6de 100644 --- a/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java +++ b/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java @@ -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 { @@ -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)));