Skip to content
Snippets Groups Projects
Commit 2a54e73e authored by Carol-Ann Donaldson's avatar Carol-Ann Donaldson
Browse files

Added unit tests to detect assignment errors - square completion and drawing lines twice

parent 3f9f831d
No related branches found
No related tags found
1 merge request!1Resolve "Fix assignment errors"
......@@ -26,6 +26,30 @@ public class DotsAndBoxesGridTest {
logger.info("Dummy test to show the test suite runs");
assertTrue(true);
}
@Test
public void testSquareCompletion() {
logger.info("Testing if square completion detection is working");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3);
// Simulate drawing lines to complete a square at (0,0)
grid.drawHorizontal(0, 0, 1);
grid.drawVertical(0, 0, 1);
grid.drawHorizontal(0, 1, 1);
grid.drawVertical(1, 0, 1);
// The square at (0,0) should be complete
assertTrue(grid.isSquareComplete(0, 0), "Square at (0,0) should be complete");
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testDrawingLineTwiceThrowsException() {
logger.info("Testing if drawing a line twice throws an IllegalStateException");
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3);
// Simulate drawing a horizontal line
grid.drawHorizontal(0, 0, 1);
// Try drawing the same horizontal line again, which should throw an IllegalStateException
assertThrows(IllegalStateException.class, () -> grid.drawHorizontal(0, 0, 1));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment