Skip to content
Snippets Groups Projects
Commit 304f9f62 authored by jphiri's avatar jphiri
Browse files

test for fixing the bug boxcomplete and drawHorizontal class

parent 57f9743d
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,58 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
void testBoxCompleteOnEdge() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2);
assertFalse(grid.boxComplete(3, 2));
}
@Test
void testBoxCompleteOnEmptyBox() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2);
assertFalse(grid.boxComplete(1, 1));
}
@Test
void testBoxCompleteOnCompletedBox() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(4, 3, 2);
grid.drawHorizontal(0, 1, 1);
grid.drawHorizontal(0, 2, 1);
grid.drawVertical(0, 1, 1);
grid.drawVertical(1, 1, 1);
assertTrue(grid.boxComplete(1, 1));
}
//end here fix me
//fix 2
@Test
public void testDrawHorizontalOutOfBounds() {
int width = 4;
int height = 3;
int players = 2;
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(width, height, players);
//out of bounce
assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(-1, 0, 1));
assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(width - 1, 0, 1));
assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(0, -1, 1));
assertThrows(IndexOutOfBoundsException.class, () -> grid.drawHorizontal(0, height, 1));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment