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

Or Elimination, Or Introduction, Not Introduction, and And Introduction Test Cases #689

Merged
merged 64 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
477dcef
Initial setup
charlestian23 Oct 13, 2023
c98c0f6
Working initial test
charlestian23 Oct 13, 2023
f037805
Added another test
charlestian23 Oct 13, 2023
918deb9
Added more tests
charlestian23 Oct 13, 2023
228698b
Added another test
charlestian23 Oct 13, 2023
79e131d
Added comments, removed useless imports, added 1 more test
charlestian23 Oct 13, 2023
c515259
Reformatting
charlestian23 Oct 13, 2023
38d25fd
Removed useless import
charlestian23 Oct 17, 2023
4cb21a0
Merge branch 'dev' into stt-test-suite
Corppet Oct 17, 2023
431ceb3
Added initial and elimination test
charlestian23 Oct 17, 2023
2fbf61e
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Oct 17, 2023
3581867
Comments and spacing
charlestian23 Oct 17, 2023
ecb1007
Another test
charlestian23 Oct 17, 2023
fe300f4
Updated comments and wrote new test
charlestian23 Oct 17, 2023
2785289
Created two new test files
charlestian23 Oct 17, 2023
f1f8fc4
Renamed test to be more descriptive
charlestian23 Oct 17, 2023
9fc175b
Added another test
charlestian23 Oct 17, 2023
301baeb
Rewrote test to be more comprehensive
charlestian23 Oct 17, 2023
71f87af
More tests :))))
charlestian23 Oct 17, 2023
767d968
Fixed test name and file
charlestian23 Oct 17, 2023
fbdc046
Fixed test
charlestian23 Oct 17, 2023
0c316c9
Fixed broken tests
charlestian23 Oct 17, 2023
93abdee
Merge branch 'dev' into stt-test-suite
charlestian23 Oct 17, 2023
f728447
Shouldn't have touched these files
charlestian23 Oct 17, 2023
a6096ad
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Oct 17, 2023
11821ce
CHECKSTYLE
charlestian23 Oct 17, 2023
8893406
Merge branch 'dev' into stt-test-suite
charlestian23 Oct 18, 2023
ca76fe6
Trying to make CheckStyle happy
charlestian23 Oct 18, 2023
e1b6aa4
Initial commit for more tests
charlestian23 Oct 24, 2023
c6ca5a1
Finished a test
charlestian23 Oct 24, 2023
1f5f426
Another test done
charlestian23 Oct 24, 2023
db43460
More tests
charlestian23 Oct 24, 2023
cb016f2
Added cannot set both at once test
charlestian23 Oct 27, 2023
1e8ee41
Conditional files
charlestian23 Oct 27, 2023
e8ce29f
Some tests done
charlestian23 Oct 27, 2023
fe2d1cb
More tests
charlestian23 Oct 27, 2023
2ea712e
Even more tests
charlestian23 Oct 27, 2023
d4f9715
Merge branch 'dev' into stt-test-suite
charlestian23 Oct 27, 2023
be30a30
Fixed comments to use biconditional symbol
charlestian23 Oct 27, 2023
8fccf2c
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Oct 27, 2023
305ebb6
Merge branch 'dev' into stt-test-suite
charlestian23 Oct 27, 2023
36556a8
Added tests for false conditional
charlestian23 Nov 3, 2023
16184e0
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Nov 3, 2023
37b401f
Fixed some broken biconditional files and added new ones
charlestian23 Nov 3, 2023
c4cf03b
Added more tests for B and fixed some descriptions
charlestian23 Nov 3, 2023
ceee626
Merge branch 'dev' into stt-test-suite
charlestian23 Nov 3, 2023
22a60ba
Checkstyle fix
charlestian23 Nov 7, 2023
042bf9d
Merge branch 'dev' into stt-test-suite
charlestian23 Nov 7, 2023
d38f8db
Added tests for Not Elimination
charlestian23 Nov 7, 2023
b24845a
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Nov 7, 2023
b2b00ec
Temporarily commenting out broken test
charlestian23 Nov 7, 2023
2f791b4
Added or elimination puzzle files
charlestian23 Nov 10, 2023
7c92e09
Renamed directory
charlestian23 Nov 10, 2023
87040de
Added Or Elimination files
charlestian23 Nov 10, 2023
4bd48bc
Added FTU and UTF tests
charlestian23 Nov 10, 2023
6c19b99
More tests
charlestian23 Nov 10, 2023
02ba918
Merge branch 'dev' into stt-test-suite
charlestian23 Nov 10, 2023
667b195
Add Or Intro tests
charlestian23 Nov 14, 2023
985b425
Merge branch 'stt-test-suite' of https://github.com/charlestian23/LEG…
charlestian23 Nov 14, 2023
5367699
Checkstyle fix
charlestian23 Nov 14, 2023
0f4a001
Spacing fix
charlestian23 Nov 14, 2023
81ee12d
Added not introduction test
charlestian23 Nov 14, 2023
f1af158
Added And Introduction tests and modified Or Introduction tests
charlestian23 Nov 17, 2023
048dc19
Merge branch 'dev' into stt-test-suite
charlestian23 Nov 17, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package puzzles.shorttruthtable.rules;

import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.introduction.DirectRuleAndIntroduction;
import edu.rpi.legup.save.InvalidFileFormatException;
import legup.MockGameBoardFacade;
import legup.TestUtilities;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

public class AndIntroductionDirectRuleTest {
private static final DirectRuleAndIntroduction RULE = new DirectRuleAndIntroduction();
private static ShortTruthTable stt;
Corppet marked this conversation as resolved.
Show resolved Hide resolved

@BeforeClass
public static void setup() {
MockGameBoardFacade.getInstance();
stt = new ShortTruthTable();
}

/**
* Given a statement: A ^ B
*
* Asserts that if at least 1 of A or B is false, then this is a valid application
* of the rule if and only if ^ is false.
*
* @param filePath The file path for test board setup.
* @throws InvalidFileFormatException
*/
@Test
public void FalseAndTest() throws InvalidFileFormatException {
String path = "puzzles/shorttruthtable/rules/AndIntroductionDirectRule/";
falseAndTestHelper(path + "FUF");
falseAndTestHelper(path + "FUU");
falseAndTestHelper(path + "UUF");
falseAndTestHelper(path + "FUT");
falseAndTestHelper(path + "TUF");
}

private void falseAndTestHelper(String filePath) throws InvalidFileFormatException {
TestUtilities.importTestBoard(filePath, stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell and = board.getCell(1, 0);

and.setData(ShortTruthTableCellType.TRUE);
board.addModifiedData(and);
Assert.assertNotNull(RULE.checkRule(transition));

and.setData(ShortTruthTableCellType.FALSE);
board.addModifiedData(and);
Assert.assertNull(RULE.checkRule(transition));
}

/**
* Given a statement: A ^ B
*
* Asserts that setting ^ to true is a valid application of the rule if
* and only if both A and B are true.
*
* @param filePath The file path for test board setup.
* @throws InvalidFileFormatException
*/
@Test
public void FalseOrTest() throws InvalidFileFormatException {
String path = "puzzles/shorttruthtable/rules/AndIntroductionDirectRule/";
String[] letters = {"T", "F", "U"};
for (String first : letters) {
for (String second : letters) {
trueAndTestHelper(path + first + "U" + second);
}
}
}

private void trueAndTestHelper(String filePath) throws InvalidFileFormatException {
TestUtilities.importTestBoard(filePath, stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell a = board.getCell(0, 0);
ShortTruthTableCell b = board.getCell(2, 0);
ShortTruthTableCell and = board.getCell(1, 0);

and.setData(ShortTruthTableCellType.TRUE);
board.addModifiedData(and);

if (a.getType() == ShortTruthTableCellType.TRUE && b.getType() == ShortTruthTableCellType.TRUE) {
Assert.assertNull(RULE.checkRule(transition));
}
else {
Assert.assertNotNull(RULE.checkRule(transition));
}
}
}
122 changes: 122 additions & 0 deletions src/test/java/puzzles/shorttruthtable/rules/NotIntroductionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package puzzles.shorttruthtable.rules;

import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.introduction.DirectRuleNotIntroduction;
import edu.rpi.legup.save.InvalidFileFormatException;
import legup.MockGameBoardFacade;
import legup.TestUtilities;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

public class NotIntroductionTest {
private static final DirectRuleNotIntroduction RULE = new DirectRuleNotIntroduction();
private static ShortTruthTable stt;

@BeforeClass
public static void setup() {
MockGameBoardFacade.getInstance();
stt = new ShortTruthTable();
}

/**
* Given one statement: ¬A where A is false
*
* Asserts that this is a valid application of this rule if and only if ¬ is true
*
* @throws InvalidFileFormatException
*/
@Test
public void FalseNot() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/FalseA", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};

for (ShortTruthTableCellType cellType : cellTypes) {
ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell not = board.getCell(0, 0);
not.setData(cellType);
board.addModifiedData(not);

if (cellType == ShortTruthTableCellType.TRUE) {
Assert.assertNull(RULE.checkRule(transition));
}
else {
Assert.assertNotNull(RULE.checkRule(transition));
}
}
}

/**
* Given one statement: ¬A where A is true
*
* Asserts that this is a valid application of this rule if and only if ¬ is false
*
* @throws InvalidFileFormatException
*/
@Test
public void TrueNot() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/TrueA", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};

for (ShortTruthTableCellType cellType : cellTypes) {
ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell not = board.getCell(0, 0);
not.setData(cellType);
board.addModifiedData(not);

if (cellType == ShortTruthTableCellType.FALSE) {
Assert.assertNull(RULE.checkRule(transition));
}
else {
Assert.assertNotNull(RULE.checkRule(transition));
}
}
}

/**
* Given one statement: ¬A
*
* Asserts that setting both ¬ and A to any values would not be a valid
* application of this rule
*
* @throws InvalidFileFormatException
*/
@Test
public void CannotSetBothAtOnceTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/NotIntroductionDirectRule/BlankA", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};

for (ShortTruthTableCellType cellType1 : cellTypes) {
for (ShortTruthTableCellType cellType2 : cellTypes) {
ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell not = board.getCell(0, 0);
ShortTruthTableCell a = board.getCell(1, 0);

not.setData(cellType1);
a.setData(cellType2);

board.addModifiedData(not);
board.addModifiedData(a);

Assert.assertNotNull(RULE.checkRule(transition));
}
}
}
}
150 changes: 150 additions & 0 deletions src/test/java/puzzles/shorttruthtable/rules/OrEliminationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package puzzles.shorttruthtable.rules;

import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.elimination.DirectRuleOrElimination;
import edu.rpi.legup.save.InvalidFileFormatException;
import legup.MockGameBoardFacade;
import legup.TestUtilities;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

public class OrEliminationTest {
private static final DirectRuleOrElimination RULE = new DirectRuleOrElimination();
private static ShortTruthTable stt;

@BeforeClass
public static void setup() {
MockGameBoardFacade.getInstance();
stt = new ShortTruthTable();
}

/**
* Given a statement: A V B, where A is false and V is true
*
* Asserts that this is a valid application of the rule if and only if B is true.
*
* @throws InvalidFileFormatException
*/
@Test
public void FTUTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/FTU", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell cell = board.getCell(2, 0);

cell.setData(ShortTruthTableCellType.TRUE);
board.addModifiedData(cell);
Assert.assertNull(RULE.checkRule(transition));

cell.setData(ShortTruthTableCellType.FALSE);
board.addModifiedData(cell);
Assert.assertNotNull(RULE.checkRule(transition));
}

/**
* Given a statement: A V B, where B is false and V is true
*
* Asserts that this is a valid application of the rule if and only if B is true.
*
* @throws InvalidFileFormatException
*/
@Test
public void UTFTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTF", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell cell = board.getCell(0, 0);

cell.setData(ShortTruthTableCellType.TRUE);
board.addModifiedData(cell);
Assert.assertNull(RULE.checkRule(transition));

cell.setData(ShortTruthTableCellType.FALSE);
board.addModifiedData(cell);
Assert.assertNotNull(RULE.checkRule(transition));
}

/**
* Given a statement: A V B, where V is false
*
* Asserts that this is a valid application of the rule if and only if both A
* and B are false.
*
* @throws InvalidFileFormatException
*/
@Test
public void UFUTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UFU", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};

for (ShortTruthTableCellType cellType1 : cellTypes) {
for (ShortTruthTableCellType cellType2 : cellTypes) {
ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell a = board.getCell(0, 0);
ShortTruthTableCell b = board.getCell(2, 0);

a.setData(cellType1);
b.setData(cellType2);

board.addModifiedData(a);
board.addModifiedData(b);

if (cellType1 == ShortTruthTableCellType.FALSE && cellType2 == ShortTruthTableCellType.FALSE) {
Assert.assertNull(RULE.checkRule(transition));
}
else {
Assert.assertNotNull(RULE.checkRule(transition));
}
}
}
}

/**
* Given a statement: A V B, where V is true
*
* Asserts that setting both A and B is not a valid application of this rule.
*
* @throws InvalidFileFormatException
*/
@Test
public void UTUTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/OrEliminationDirectRule/UTU", stt);
TreeNode rootNode = stt.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

ShortTruthTableCellType[] cellTypes = {ShortTruthTableCellType.TRUE, ShortTruthTableCellType.FALSE, ShortTruthTableCellType.UNKNOWN};

for (ShortTruthTableCellType cellType1 : cellTypes) {
for (ShortTruthTableCellType cellType2 : cellTypes) {
ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
ShortTruthTableCell a = board.getCell(0, 0);
ShortTruthTableCell b = board.getCell(2, 0);

a.setData(cellType1);
b.setData(cellType2);

board.addModifiedData(a);
board.addModifiedData(b);

Assert.assertNotNull(RULE.checkRule(transition));
}
}
}
}
Loading
Loading