Skip to content
Snippets Groups Projects
Commit 0ca78f9c authored by Padinharayil Anoop's avatar Padinharayil Anoop
Browse files

Added unit tests for DotsAndBoxesGrid

parent 5e43d8c8
No related branches found
No related tags found
No related merge requests found
......@@ -27,5 +27,30 @@ public class DotsAndBoxesGridTest {
assertTrue(true);
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testSquareCompletion() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
// Draw the four lines of a box
grid.drawHorizontal(0, 0, 1);
grid.drawHorizontal(0, 1, 1);
grid.drawVertical(0, 0, 1);
grid.drawVertical(1, 0, 1);
// Check if the box is indeed complete
assertTrue(grid.boxComplete(0, 0));
}
@Test
public void testDrawExistingLine() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
// Draw a line
grid.drawHorizontal(0, 0, 1);
// Attempt to draw the same line again. This should throw an IllegalStateException.
assertThrows(IllegalStateException.class, () -> {
grid.drawHorizontal(0, 0, 1);
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment