diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java index 1aac7ccc87bd5620cdcd1db9b008f20a08d50640..763162700303b93f02056b0ddf5f9992634923ea 100644 --- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java +++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java @@ -21,6 +21,7 @@ public class DotsAndBoxesGridTest { * * This is a dummy test just to show that the test suite itself runs */ + @Test public void testTestSuiteRuns() { logger.info("Dummy test to show the test suite runs"); @@ -28,4 +29,29 @@ public class DotsAndBoxesGridTest { } // FIXME: You need to write tests for the two known bugs in the code. + + // Test if algorithm for testing whether a box is complete is wrong + @Test + public void completeBoxTest() { + logger.info("Test to see if completion algorithm is working"); + + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2); + // draw a complete square + grid.drawHorizontal(1,1,1); + grid.drawHorizontal(1,2,1); + grid.drawVertical(1,2,1); + assertTrue(grid.drawVertical(2,2,1)); + } + + // Test that DotsAndBoxesGrid currently allows drawing a line on an existing line + @Test + public void gridLineException() { + logger.info("Should not be able to draw a line over an already existing line"); + + DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,2,2); + grid.drawHorizontal(1,1,1); + // assert error here + assertThrows(RuntimeException.class, () -> grid.drawHorizontal(1,1,2), "Line was drawn over another"); + + } }