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

Add failing unit tests for assignment errors.

parent a09bf5c9
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 only three lines of a box
grid.drawHorizontal(0, 0, 1);
grid.drawVertical(0, 0, 1);
grid.drawVertical(1, 0, 1);
// Check if the box is indeed incomplete
assertFalse(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.
Finish editing this message first!
Please register or to comment