Skip to content
Snippets Groups Projects
Commit 88c938c4 authored by Scott Crooks's avatar Scott Crooks
Browse files

Implemented tests for boxComplete and drawVertical/Horizontal

parent c46bd751
No related branches found
No related tags found
1 merge request!1Resolve "Fix errors in assignment"
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
......@@ -28,4 +28,60 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testBoxCompleteFull() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
grid.drawHorizontal(0, 0, 1);
grid.drawHorizontal(0, 1, 1);
grid.drawVertical(0, 0, 1);
grid.drawVertical(1, 0, 1);
assertTrue(grid.boxComplete(0, 0));
}
@Test
public void testBoxCompletePartial() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
grid.drawHorizontal(1, 1, 1);
grid.drawVertical(1, 1, 1);
grid.drawVertical(2, 1, 1);
assertFalse(grid.boxComplete(1, 1));
}
@Test
public void testDrawVerticalOnce() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
assertFalse(grid.drawVertical(1, 1, 1));
}
@Test
public void testVerticalCannotBeRedrawn() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
grid.drawVertical(1, 1, 1);
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
grid.drawVertical(1, 1, 2);
});
assertTrue(exception instanceof IllegalArgumentException);
}
@Test
public void testDrawHorizontalOnce() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
assertFalse(grid.drawHorizontal(1, 1, 1));
}
@Test
public void testHorizontalCannotBeRedrawn() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
grid.drawHorizontal(1, 1, 1);
Exception exception = assertThrows(IllegalStateException.class, () -> {
grid.drawHorizontal(1, 1, 2);
});
assertTrue(exception instanceof IllegalArgumentException);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment