Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeandtea committed Apr 9, 2024
1 parent 5819bf8 commit 806f9a0
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void setUp() {
* and a clue of 0 tents in the row.
*
* <p>checks that 1 case is created and that it is equivalent to FinishWithGrass rule
* May need to change checks due to issue #777
*
* @throws InvalidFileFormatException
*/
Expand Down Expand Up @@ -318,8 +319,8 @@ public void FillInRowEmptyThreeTentClue() throws InvalidFileFormatException {
}

/**
* empty 5x5 TreeTent puzzle Tests FillinRowCaseRule on row with 3 UNKNOWN tiles separated
* by 2 GRASS tiles and a clue of 2 tents in the row.
* empty 5x5 TreeTent puzzle Tests FillinRowCaseRule on row with 5 UNKNOWN tiles
* and a clue of 2 tents in the row.
*
* <p>checks that 6 cases are created and each case has the right number of tents
*
Expand Down
96 changes: 48 additions & 48 deletions src/test/java/puzzles/treetent/rules/LinkTentCaseRuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,54 @@ public static void setUp() {
treetent = new TreeTent();
}

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tent
* with one tree surrounding it.
*
* <p>checks that 1 cases is with the line connecting the central tent and the tree
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentOneTreeTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTentCaseRule/OneTreeOneTent", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

TreeTentBoard board = (TreeTentBoard) transition.getBoard();
TreeTentCell test_location = board.getCell(1, 1);
ArrayList<Board> cases = RULE.getCases(board, test_location);

// assert that one cases was found
Assert.assertEquals(1, cases.size());
TreeTentBoard testCase = (TreeTentBoard) cases.getFirst();

TreeTentLine expectedLine = new TreeTentLine(board.getCell(1, 1), board.getCell(1, 0));

ArrayList<TreeTentLine> lines = testCase.getLines();

// One line connecting the tree to the tent
Assert.assertEquals(1, lines.size());
TreeTentLine line = lines.getFirst();

// Expected line
Assert.assertTrue(line.compare(expectedLine));

// checks other cells have not been modified
TreeTentCell original_cell;
TreeTentCell case_cell;

for (int w = 0; w < board.getWidth(); w++) {
for (int h = 0; h < board.getHeight(); h++) {
original_cell = board.getCell(w, h);
case_cell = testCase.getCell(w, h);
Assert.assertEquals(original_cell.getType(), case_cell.getType());
}
}
}

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tent
* with four trees surrounding it.
Expand Down Expand Up @@ -93,54 +141,6 @@ public void LinkTentFourTreesTest() throws InvalidFileFormatException {
}
}

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tent
* with one tree surrounding it.
*
* <p>checks that 1 cases is with the line connecting the central tent and the tree
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentOneTreeTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTentCaseRule/OneTreeOneTent", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

TreeTentBoard board = (TreeTentBoard) transition.getBoard();
TreeTentCell test_location = board.getCell(1, 1);
ArrayList<Board> cases = RULE.getCases(board, test_location);

// assert that one cases was found
Assert.assertEquals(1, cases.size());
TreeTentBoard testCase = (TreeTentBoard) cases.getFirst();

TreeTentLine expectedLine = new TreeTentLine(board.getCell(1, 1), board.getCell(1, 0));

ArrayList<TreeTentLine> lines = testCase.getLines();

// One line connecting the tree to the tent
Assert.assertEquals(1, lines.size());
TreeTentLine line = lines.getFirst();

// Expected line
Assert.assertTrue(line.compare(expectedLine));

// checks other cells have not been modified
TreeTentCell original_cell;
TreeTentCell case_cell;

for (int w = 0; w < board.getWidth(); w++) {
for (int h = 0; h < board.getHeight(); h++) {
original_cell = board.getCell(w, h);
case_cell = testCase.getCell(w, h);
Assert.assertEquals(original_cell.getType(), case_cell.getType());
}
}
}

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tent
* with zero trees around it.
Expand Down
104 changes: 52 additions & 52 deletions src/test/java/puzzles/treetent/rules/LinkTreeCaseRuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public static void setUp() {

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tree
* with zero tents around it.
* with one tent above
*
* <p> Ensures no cases are created
* <p> Ensures one case is created that connects the tree to the tent.
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentNoTreesTest() throws InvalidFileFormatException {
public void LinkTentOneTentTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTreeCaseRule/NoTents", treetent);
"puzzles/treetent/rules/LinkTreeCaseRule/OneTent", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand All @@ -49,31 +49,31 @@ public void LinkTentNoTreesTest() throws InvalidFileFormatException {
ArrayList<Board> cases = RULE.getCases(board, test_location);

// assert that no cases were found
Assert.assertEquals(0, cases.size());
}
Assert.assertEquals(1, cases.size());
TreeTentBoard testCase = (TreeTentBoard) cases.getFirst();

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tree
* with tents on a diagonal.
*
* <p> Ensures no cases are created
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentDiagTentsTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTreeCaseRule/NoTents", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
TreeTentLine expectedLine = new TreeTentLine(board.getCell(1, 1), board.getCell(1, 0));

TreeTentBoard board = (TreeTentBoard) transition.getBoard();
TreeTentCell test_location = board.getCell(1, 1);
ArrayList<Board> cases = RULE.getCases(board, test_location);
ArrayList<TreeTentLine> lines = testCase.getLines();

// assert that no cases were found
Assert.assertEquals(0, cases.size());
// One line connecting the tree to the tent
Assert.assertEquals(1, lines.size());
TreeTentLine line = lines.getFirst();

// Expected line
Assert.assertTrue(line.compare(expectedLine));

// checks other cells have not been modified
TreeTentCell original_cell;
TreeTentCell case_cell;

for (int w = 0; w < board.getWidth(); w++) {
for (int h = 0; h < board.getHeight(); h++) {
original_cell = board.getCell(w, h);
case_cell = testCase.getCell(w, h);
Assert.assertEquals(original_cell.getType(), case_cell.getType());
}
}
}

/**
Expand Down Expand Up @@ -144,16 +144,16 @@ public void LinkTentTwoTentsTest() throws InvalidFileFormatException {

/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tree
* with one tent above
* with zero tents around it.
*
* <p> Ensures one case is created that connects the tree to the tent.
* <p> Ensures no cases are created
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentOneTentTest() throws InvalidFileFormatException {
public void LinkTentNoTreesTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTreeCaseRule/OneTent", treetent);
"puzzles/treetent/rules/LinkTreeCaseRule/NoTents", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
Expand All @@ -163,30 +163,30 @@ public void LinkTentOneTentTest() throws InvalidFileFormatException {
ArrayList<Board> cases = RULE.getCases(board, test_location);

// assert that no cases were found
Assert.assertEquals(1, cases.size());
TreeTentBoard testCase = (TreeTentBoard) cases.getFirst();

TreeTentLine expectedLine = new TreeTentLine(board.getCell(1, 1), board.getCell(1, 0));

ArrayList<TreeTentLine> lines = testCase.getLines();

// One line connecting the tree to the tent
Assert.assertEquals(1, lines.size());
TreeTentLine line = lines.getFirst();
Assert.assertEquals(0, cases.size());
}

// Expected line
Assert.assertTrue(line.compare(expectedLine));
/**
* empty 3x3 TreeTent puzzle Tests LinkTentCaseRule on a central tree
* with tents on a diagonal.
*
* <p> Ensures no cases are created
*
* @throws InvalidFileFormatException
*/
@Test
public void LinkTentDiagTentsTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/LinkTreeCaseRule/NoTents", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

// checks other cells have not been modified
TreeTentCell original_cell;
TreeTentCell case_cell;
TreeTentBoard board = (TreeTentBoard) transition.getBoard();
TreeTentCell test_location = board.getCell(1, 1);
ArrayList<Board> cases = RULE.getCases(board, test_location);

for (int w = 0; w < board.getWidth(); w++) {
for (int h = 0; h < board.getHeight(); h++) {
original_cell = board.getCell(w, h);
case_cell = testCase.getCell(w, h);
Assert.assertEquals(original_cell.getType(), case_cell.getType());
}
}
// assert that no cases were found
Assert.assertEquals(0, cases.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<cells>
<cell value="2" x="1" y="0"/>
<cell value="2" x="1" y="2"/>
<cell value="2" x="1" y="4"/>
<cell value="2" x="1" y="6"/>
<cell value="1" x="1" y="4"/>
<cell value="1" x="1" y="6"/>
</cells>
<axis side="east">
<clue index="A" value="0"/>
Expand Down

0 comments on commit 806f9a0

Please sign in to comment.