diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1946beda974d180686c65c0259a7b881e9a4eb5a..136f829bf96483e07f046831d93767c734188728 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 boxCompleteDetectsCompletedBoxes() { + // A grid where we're going to draw a box, and then test whether it's complete + DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2); + case1.drawHorizontal(0, 0, 0); + case1.drawVertical(0, 0, 1); + case1.drawHorizontal(0, 1, 0); + case1.drawVertical(1, 0, 1); + + assertTrue(case1.boxComplete(0, 0)); + assertTrue(case1.boxComplete(1, 1)); + assertTrue(case1.getHorizontal(0, 0)&&case1.getVertical(0, 0)); + assertTrue(case1.getHorizontal(1, 0)&&case1.getVertical(1, 0)); + + } + + @Test + public void drawHorizontalTest() { + DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2); + case1.drawHorizontal(0, 0, 0); + case1.drawVertical(0, 0, 1); + case1.drawHorizontal(0, 1, 0); + case1.drawVertical(1, 0, 1); + + assertThrows(RuntimeException.class, () -> {case1.drawHorizontal(0, 0, 0);}); + } }