Skip to content

Commit

Permalink
Automated Java code formatting changes (#786)
Browse files Browse the repository at this point in the history
Co-authored-by: Bram van Heuveln <bram28@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and Bram28 authored Mar 30, 2024
1 parent b1c8c2f commit 9270d0e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/test/java/legup/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void main(String[] args) {
Result result13 = JUnitCore.runClasses(TooManyBulbsContradictionRuleTest.class);
printTestResults(result13);

//nurikabe tests
// nurikabe tests
Result result14 = JUnitCore.runClasses(BlackBetweenRegionsDirectRuleTest.class);
printTestResults(result14);
Result result15 = JUnitCore.runClasses(BlackBottleNeckDirectRuleTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,48 @@ public class FinishWithEmptyDirectRuleTest {
private static LightUp lightUp;

@BeforeClass
public static void setUp() { lightUp = new LightUp(); }
public static void setUp() {
lightUp = new LightUp();
}

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

//get board state
// get board state
LightUpBoard board = (LightUpBoard) transition.getBoard();
// The board has a "1" clue at (1,1) with a bulb one space above at (1,0);

//change the board's cells considering the FinishWithEmpty rule to empty
LightUpCell cell1 = board.getCell(0,1); //left
// change the board's cells considering the FinishWithEmpty rule to empty
LightUpCell cell1 = board.getCell(0, 1); // left
cell1.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell1);

LightUpCell cell2 = board.getCell(2,1); //right
LightUpCell cell2 = board.getCell(2, 1); // right
cell2.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell2);

LightUpCell cell3 = board.getCell(1,2); //below
LightUpCell cell3 = board.getCell(1, 2); // below
cell3.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell3);

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

//check every square except the top center (2,0)
// check every square except the top center (2,0)
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 == 1 && j == 0) || (i == 1 && j == 2) || (i == 2 && j == 1)){
//logically follows
if ((i == 1 && j == 0) || (i == 1 && j == 2) || (i == 2 && j == 1)) {
// logically follows
Assert.assertNull(RULE.checkRuleAt(transition, c));
}
else {
//does not use the rule to logically follow
} else {
// does not use the rule to logically follow
Assert.assertNotNull(RULE.checkRuleAt(transition, c));
}
}
Expand All @@ -66,34 +68,35 @@ public void FinishEmptyTestWithOne() throws InvalidFileFormatException {

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

//get board state
// get board state
LightUpBoard board = (LightUpBoard) transition.getBoard();
// The board has a "3" clue at (1,1) with a bulbs at (0,1), (2,1), and (1,2)

//change the board's cells considering the FinishWithBulbs rule to empty
LightUpCell cell1 = board.getCell(1,0);
// change the board's cells considering the FinishWithBulbs rule to empty
LightUpCell cell1 = board.getCell(1, 0);
cell1.setData(LightUpCellType.EMPTY.value);
board.addModifiedData(cell1);

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

//check every square for logical following
// check every square for logical following
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 == 0 && j == 1){
//logically follows
if (i == 0 && j == 1) {
// logically follows
Assert.assertNull(RULE.checkRuleAt(transition, c));
}
else {
//does not use the rule to logically follow
} else {
// does not use the rule to logically follow
Assert.assertNotNull(RULE.checkRuleAt(transition, c));
}
}
Expand Down

0 comments on commit 9270d0e

Please sign in to comment.