Skip to content
Snippets Groups Projects
Commit 3cff0b8d authored by mthoma48's avatar mthoma48
Browse files

Initial unit tests for Issue 1 bugs, completeBoxTest and gridLineException

parent 29c1ff34
Branches
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ public class DotsAndBoxesGridTest {
*
* This is a dummy test just to show that the test suite itself runs
*/
@Test
public void testTestSuiteRuns() {
logger.info("Dummy test to show the test suite runs");
......@@ -28,4 +29,29 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
// Test if algorithm for testing whether a box is complete is wrong
@Test
public void completeBoxTest() {
logger.info("Test to see if completion algorithm is working");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2);
// draw a complete square
grid.drawHorizontal(1,1,1);
grid.drawHorizontal(1,2,1);
grid.drawVertical(1,2,1);
assertTrue(grid.drawVertical(2,2,1));
}
// Test that DotsAndBoxesGrid currently allows drawing a line on an existing line
@Test
public void gridLineException() {
logger.info("Should not be able to draw a line over an already existing line");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2);
grid.drawHorizontal(1,1,1);
// assert error here
assertThrows(RuntimeException.class, () -> grid.drawHorizontal(1,1,2), "Line was drawn over another");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment