Skip to content

Commit

Permalink
Finished working on EmptyCornersDirectRuleTest. Cases where the rule …
Browse files Browse the repository at this point in the history
…was used wrongly were not tested so I changed the puzzle file and the testing code accordingly to make some extra tests. The tests worked correctly and so the rule works :) (#698)
  • Loading branch information
pitbull51067 authored Dec 13, 2023
1 parent 9eb5075 commit 05b310b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'Legup'
rootProject.name = 'LEGUP'
include ':legup'
include ':legup-update'

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public void EmptyCornersTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/EmptyCornersDirectRule/EmptyCorners", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
transition.setRule(RULE);

//get board state
LightUpBoard board = (LightUpBoard) transition.getBoard();

Expand All @@ -42,16 +42,32 @@ public void EmptyCornersTest() throws InvalidFileFormatException {
cell2.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell2);

LightUpCell cell3 = board.getCell(4,3);
cell3.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell3);

//confirm there is a logical following of the EmptyCorners rule
Assert.assertNull(RULE.checkRule(transition));

//this should not be accepted, the cell should remain unknown
LightUpCell cell4 = board.getCell(4,5);
cell4.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell4);

//this should not be accepted, the cell should be empty but not because of this rule
LightUpCell cell5 = board.getCell(4,1);
cell5.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell5);

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

//confirm the two expected cells are emptied USING THE RULE
// and none of the rest are (others can be empty just not by the same rule)
LightUpCell c;
for (int i = 0; i < board.getHeight(); i++) {
for (int j = 0; j < board.getWidth(); j++) {
c = board.getCell(j, i);
if ((i == 2 && j == 0) || (i == 2 && j == 2)){
if ((i == 2 && j == 0) || (i == 2 && j == 2) || (i==3 && j==4)){
Assert.assertNull(RULE.checkRuleAt(transition, c));
}
else {
Expand All @@ -60,4 +76,4 @@ public void EmptyCornersTest() throws InvalidFileFormatException {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<Legup>
<puzzle name="LightUp">
<board width="3" height="3">
<board width="6" height="6">
<cells>
<cell value="3" x="1" y="1"/>
<cell value="-4" x="1" y="0"/>
<cell value="2" x="3" y="4"/>
<cell value="2" x="5" y="2"/>
<cell value="-4" x="2" y="4"/>
<cell value="-4" x="5" y="1"/>
</cells>
</board>
</puzzle>
Expand Down

0 comments on commit 05b310b

Please sign in to comment.