diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..851da9b10ce309c842ff31e0508f8ae686e3cddb 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -27,5 +27,30 @@ public class DotsAndBoxesGridTest { assertTrue(true); } - // FIXME: You need to write tests for the two known bugs in the code. + @Test +public void testSquareCompletion() { + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); + + // Draw only three lines of a box + grid.drawHorizontal(0, 0, 1); + grid.drawVertical(0, 0, 1); + grid.drawVertical(1, 0, 1); + + // Check if the box is indeed incomplete + assertFalse(grid.boxComplete(0, 0)); +} + +@Test +public void testDrawExistingLine() { + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); + + // Draw a line + grid.drawHorizontal(0, 0, 1); + + // Attempt to draw the same line again. This should throw an IllegalStateException. + assertThrows(IllegalStateException.class, () -> { + grid.drawHorizontal(0, 0, 1); + }); +} + }