Skip to content
Snippets Groups Projects
Commit c0912dab authored by Ethan Carlsson's avatar Ethan Carlsson
Browse files

tests for boxComplete and draw functions

parent 67ef27c8
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,34 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testDrawHorizontalThrows() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(2, 2, 2);
grid.drawHorizontal(0,0, 1);
assertThrows(Exception.class, () -> {
grid.drawHorizontal(0,0, 1);
});
}
@Test
public void testDrawVerticalThrows() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(2, 2, 2);
grid.drawVertical(0,0, 1);
assertThrows(Exception.class, () -> {
grid.drawVertical(0,0, 1);
});
}
@Test
public void testBoxComplete () {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(2, 2, 2);
grid.drawVertical(0, 0, 1);
assertFalse(grid.boxComplete(0, 0));
grid.drawVertical(1, 0, 1);
assertFalse(grid.boxComplete(1, 0));
grid.drawHorizontal(0, 0, 1);
assertFalse(grid.boxComplete(0, 0));
grid.drawHorizontal(0, 1, 1);
assertTrue(grid.boxComplete(0, 1));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment