diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..a4fc127deec7956bf51be424dc9bbde3c3063487 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -28,4 +28,58 @@ public class DotsAndBoxesGridTest { } // FIXME: You need to write tests for the two known bugs in the code. + @Test + void testBoxCompleteOnEdge() { + + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2); + + + assertFalse(grid.boxComplete(3, 2)); + } + + @Test + void testBoxCompleteOnEmptyBox() { + + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2); + + + assertFalse(grid.boxComplete(1, 1)); + } + + @Test + void testBoxCompleteOnCompletedBox() { + + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2); + + + grid.drawHorizontal(0, 1, 1); + grid.drawHorizontal(0, 2, 1); + grid.drawVertical(0, 1, 1); + grid.drawVertical(1, 1, 1); + + + assertTrue(grid.boxComplete(1, 1)); + } + + + + //end here fix me + + //fix 2 + + + @Test + public void testDrawHorizontalOutOfBounds() { + int width = 4; + int height = 3; + int players = 2; + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(width, height, players); + + //out of bounce + assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(-1, 0, 1)); + assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(width - 1, 0, 1)); + assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(0, -1, 1)); + assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(0, height, 1)); + } + }