Skip to content
Snippets Groups Projects

Resolve "Fix errors in assignment"

Merged Scott Crooks requested to merge 1-fix-errors-in-assignment into main
1 file
+ 56
0
Compare changes
  • Side-by-side
  • Inline
@@ -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);
}
}
Loading