Skip to content

Commit

Permalink
added another test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-771 committed Oct 27, 2023
1 parent 8b34ffc commit 4c4e776
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,70 @@ public void TooManyTentsTest() throws InvalidFileFormatException {
}
}
}

@Test
public void AmbiguousTentsTest () throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithTentsDirectRule/AmbiguousTents", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

TreeTentBoard board = (TreeTentBoard) transition.getBoard();

TreeTentCell cell = board.getCell(0, 1);
cell.setData(TreeTentType.TENT);
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)));
}
}

cell.setData(TreeTentType.UNKNOWN);
board.addModifiedData(cell);
cell = board.getCell(1, 0);
cell.setData(TreeTentType.TENT);
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)));
}
}

cell.setData(TreeTentType.UNKNOWN);
board.addModifiedData(cell);
cell = board.getCell(2, 1);
cell.setData(TreeTentType.TENT);
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)));
}
}

cell.setData(TreeTentType.UNKNOWN);
board.addModifiedData(cell);
cell = board.getCell(1, 2);
cell.setData(TreeTentType.TENT);
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Legup>
<puzzle name="TreeTent">
<board height="3" width="3">
<cells>
<cell value="3" x="1" y="1"/>
</cells>
<axis side="east">
<clue index="A" value="0"/>
<clue index="B" value="2"/>
<clue index="C" value="0"/>
</axis>
<axis side="south">
<clue index="1" value="0"/>
<clue index="2" value="2"/>
<clue index="3" value="0"/>
</axis>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>

0 comments on commit 4c4e776

Please sign in to comment.