Skip to content

Commit

Permalink
Test suite branch (#685)
Browse files Browse the repository at this point in the history
* BulbsInPathContradictionRuleTest looks good. I added one more function to check for the BlockInHorizontalPath test case.

* I think I might have run into a problem on the testing function. I will confirm this problem next time and will write another test case.

* I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases.

* I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases.

---------

Co-authored-by: Chase Grajeda <[email protected]>
Co-authored-by: Charles Tian <[email protected]>
  • Loading branch information
3 people authored Nov 9, 2023
1 parent 0e2d70b commit d749c84
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void BulbsInPathContradictionRule_LightInHorizontalPath() throws InvalidF
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));


Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
}

Expand Down Expand Up @@ -67,4 +68,19 @@ public void BulbsInPathContradictionRule_BlockInVerticalPath() throws InvalidFil

Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
}

@Test
public void BulbsInPathContradictionRule_BlockInHorizontalPath() throws InvalidFileFormatException{
TestUtilities.importTestBoard("puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

LightUpBoard board = (LightUpBoard) transition.getBoard();
Assert.assertNotNull(RULE.checkContradiction(board));
Assert.assertNotNull(RULE.checkContradictionAt(board,board.getCell(0,0)));
Assert.assertNotNull(RULE.checkContradictionAt(board,board.getCell(2,0)));
Assert.assertNotNull(RULE.checkContradictionAt(board,board.getCell(1,1)));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public static void setUp() {
lightUp = new LightUp();
}

@Test
@Test
//extensive full testing of null and non-null in a 5x5 board
public void FullLightTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/FullLightTest", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
transition.setRule(RULE);

LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
Expand All @@ -36,21 +36,21 @@ public void FullLightTest() throws InvalidFileFormatException {
//confirm it is impossible to light up these squares
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));

//confirm these are not required to be lit because they are already lit or unable to be
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
}

@Test
@Test
//simple contradiction testing for null and non-null in a 3x3 board
public void CannotLightMiddleTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CannotLight", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
transition.setRule(RULE);

LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
Expand All @@ -68,4 +68,24 @@ public void CannotLightMiddleTest() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
}

@Test
public void CanLightTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is not a contradiction somewhere on the board
Assert.assertNotNull(RULE.checkContradiction(board));

//confirm that these cells can be lit, are already lit, or that they are just black blocks
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Legup>
<puzzle name="LightUp">
<board width="3" height="3">
<cells>
<cell value="-4" x="0" y="0"/>
<cell value="-1" x="1" y="0"/>
<cell value="-4" x="2" y="0"/>
</cells>
</board>
</puzzle>
</Legup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Legup>
<puzzle name="LightUp">
<board width="5" height="5">
<cells>
<cell value="-2" x="1" y="0"/>
<cell value="-4" x="2" y="1"/>
<cell value="-4" x="0" y="4"/>
<cell value="-4" x="4" y="2"/>
<cell value="-2" x="1" y="1"/>
<cell value="-1" x="1" y="2"/>
<cell value="-1" x="2" y="3"/>
<cell value="-2" x="1" y="3"/>
<cell value="-3" x="3" y="2"/>
<cell value="-3" x="3" y="3"/>
</cells>
</board>
</puzzle>
</Legup>

0 comments on commit d749c84

Please sign in to comment.