diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..5244dbb129eb1d6d7bc29656ba6cee6861a75568 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -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)); + } }