Skip to content
Snippets Groups Projects
Commit fc89506b authored by Will Billingsley's avatar Will Billingsley
Browse files

Added test units to detect the errors

parent e6f6f37a
No related branches found
No related tags found
No related merge requests found
......@@ -27,5 +27,43 @@ public class DotsAndBoxesGridTest {
assertTrue(true);
}
@Test
public void testBoxComplete(){
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4,4,2);
//Drawing lines
grid.drawHorizontal(1,1,1);
grid.drawHorizontal(1,2,1);
grid.drawVertical(1,1,1);
grid.drawVertical(2,1,1);
//The box
assertTrue(grid.BoxComplete(1, 1));
}
@Test
public void testDrawAlreadyDrawnLine() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 4, 2);
// Drawing a horizontal line at (1, 1)
grid.drawHorizontal(1, 1, 1);
// Attempting to draw the same horizontal line again should throw an IllegalStateException
Exception exception = assertThrows(IllegalStateException.class, () -> {
grid.drawHorizontal(1, 1, 1);
});
assertEquals("Horizontal line at (1, 1) is already drawn.", exception.getMessage());
// Drawing a vertical line at (1, 1)
grid.drawVertical(1, 1, 1);
// Attempting to draw the same vertical line again should throw an IllegalStateException
exception = assertThrows(IllegalStateException.class, () -> {
grid.drawVertical(1, 1, 1);
});
assertEquals("Vertical line at (1, 1) is already drawn.", exception.getMessage());
}
// FIXME: You need to write tests for the two known bugs in the code.
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment