-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added another set of tests for TooManyBulbsContradictionRule
- Loading branch information
Showing
6 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Legup> | ||
<puzzle name="LightUp"> | ||
<board width="3" height="3"> | ||
<cells> | ||
<cell value="-4" x="0" y="1"/> | ||
<cell value="-4" x="1" y="0"/> | ||
<cell value="1" x="1" y="1"/> | ||
<cell value="-4" x="1" y="2"/> | ||
<cell value="-4" x="2" y="1"/> | ||
</cells> | ||
</board> | ||
</puzzle> | ||
</Legup> |
15 changes: 15 additions & 0 deletions
15
...urces/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Legup> | ||
<puzzle name="LightUp"> | ||
<board width="3" height="3"> | ||
<cells> | ||
<cell value="-4" x="0" y="0"/> | ||
<cell value="1" x="0" y="1"/> | ||
<cell value="-3" x="0" y="2"/> | ||
<cell value="-4" x="1" y="1"/> | ||
<cell value="-3" x="2" y="0"/> | ||
<cell value="1" x="2" y="1"/> | ||
<cell value="-4" x="2" y="2"/> | ||
</cells> | ||
</board> | ||
</puzzle> | ||
</Legup> |
11 changes: 11 additions & 0 deletions
11
build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="1" x="0" y="0"/> | ||
<cell value="-4" x="0" y="1"/> | ||
<cell value="-4" x="1" y="0"/> | ||
</cells> | ||
</board> | ||
</puzzle> | ||
</Legup> |
17 changes: 17 additions & 0 deletions
17
build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Legup> | ||
<puzzle name="LightUp"> | ||
<board width="3" height="3"> | ||
<cells> | ||
<cell value="-4" x="0" y="0"/> | ||
<cell value="1" x="0" y="1"/> | ||
<cell value="-4" x="0" y="2"/> | ||
<cell value="2" x="1" y="0"/> | ||
<cell value="-4" x="1" y="1"/> | ||
<cell value="1" x="1" y="2"/> | ||
<cell value="-4" x="2" y="0"/> | ||
<cell value="3" x="2" y="1"/> | ||
<cell value="-4" x="2" y="2"/> | ||
</cells> | ||
</board> | ||
</puzzle> | ||
</Legup> |
1 change: 0 additions & 1 deletion
1
src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 80 additions & 2 deletions
82
src/test/java/puzzles/lightup/rules/TooManyBulbsContradictionRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,97 @@ | ||
package puzzles.lightup.rules; | ||
|
||
import edu.rpi.legup.puzzle.lightup.LightUpBoard; | ||
import edu.rpi.legup.puzzle.lightup.rules.TooManyBulbsContradictionRule; | ||
import legup.MockGameBoardFacade; | ||
import legup.TestUtilities; | ||
import edu.rpi.legup.model.PuzzleImporter; | ||
import edu.rpi.legup.model.tree.TreeNode; | ||
import edu.rpi.legup.model.tree.TreeTransition; | ||
import org.junit.Assert; | ||
import edu.rpi.legup.puzzle.lightup.LightUp; | ||
import edu.rpi.legup.save.InvalidFileFormatException; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import edu.rpi.legup.puzzle.lightup.LightUp; | ||
|
||
public class TooManyBulbsContradictionRuleTest { | ||
private static final TooManyBulbsContradictionRule RULE = new TooManyBulbsContradictionRule(); | ||
private static LightUp lightUp; | ||
private static PuzzleImporter importer; | ||
|
||
@BeforeClass | ||
public static void setUp() { | ||
MockGameBoardFacade.getInstance(); | ||
lightUp = new LightUp(); | ||
importer = lightUp.getImporter(); | ||
} | ||
@Test | ||
public void TooManyBulbsContradictionRule_BlockEnclosed() throws InvalidFileFormatException { | ||
TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed", lightUp); | ||
TreeNode rootNode = lightUp.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
LightUpBoard board = (LightUpBoard) transition.getBoard(); | ||
Assert.assertNull(RULE.checkContradiction(board)); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); | ||
} | ||
|
||
@Test | ||
public void simpleCaseTest() { | ||
public void TooManyBulbsContradictionRule_CornerBlockEnclosed() throws InvalidFileFormatException { | ||
TestUtilities.importTestBoard("puzzles/lightup/rules/TooManybulbsContradictionRule/CornerBlockEnclosed", lightUp); | ||
TreeNode rootNode = lightUp.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
LightUpBoard board = (LightUpBoard) transition.getBoard(); | ||
Assert.assertNull(RULE.checkContradiction(board)); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); | ||
} | ||
// | ||
@Test | ||
public void TooManyBulbsContradictionRule_ManyBlocksEnclosed() throws InvalidFileFormatException { | ||
TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed", lightUp); | ||
TreeNode rootNode = lightUp.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
LightUpBoard board = (LightUpBoard) transition.getBoard(); | ||
Assert.assertNull(RULE.checkContradiction(board)); | ||
|
||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 2))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); | ||
} | ||
|
||
@Test | ||
public void TooManyBulbsContradictionRule_CompleteBoardBlockEnclosed() throws InvalidFileFormatException { | ||
TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed", lightUp); | ||
TreeNode rootNode = lightUp.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
LightUpBoard board = (LightUpBoard) transition.getBoard(); | ||
Assert.assertNull(RULE.checkContradiction(board)); | ||
|
||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); | ||
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); | ||
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); | ||
} | ||
} |