diff --git a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java index b595fec15..0e7930751 100644 --- a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java @@ -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))); } @@ -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))); + + } } diff --git a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java index 447476dbb..7b3ffd2b9 100644 --- a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java @@ -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 @@ -36,7 +36,7 @@ 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))); @@ -44,13 +44,13 @@ public void FullLightTest() throws InvalidFileFormatException { 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 @@ -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))); + } } diff --git a/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath b/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath new file mode 100644 index 000000000..3c8786e54 --- /dev/null +++ b/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest b/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest new file mode 100644 index 000000000..4169bf382 --- /dev/null +++ b/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file