Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Java code formatting changes #786

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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