Skip to content
Snippets Groups Projects
Commit 7bdbd0fb authored by Daniel Andrews's avatar Daniel Andrews
Browse files

Added unit tests for 2 errors

parent d7018e39
No related branches found
No related tags found
No related merge requests found
...@@ -28,4 +28,23 @@ public class DotsAndBoxesGridTest { ...@@ -28,4 +28,23 @@ public class DotsAndBoxesGridTest {
} }
// FIXME: You need to write tests for the two known bugs in the code. // FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testCompleteBox() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawHorizontal(0,0,1);
grid.drawVertical(0,0,1);
grid.drawHorizontal(0,1,1);
assertTrue(grid.drawVertical(1,0,1));
}
@Test
public void testLineDrawn() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(15, 8, 2);
grid.drawHorizontal(1,1,1);
Throwable exception = assertThrows(IllegalStateException.class, () -> grid.drawHorizontal(1,1,1));
assertEquals("This line has already been drawn.", exception.getMessage());
grid.drawVertical(1,1,1);
Throwable exception2 = assertThrows(IllegalStateException.class, () -> grid.drawVertical(1,1,1));
assertEquals("This line has already been drawn.", exception2.getMessage());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment