Skip to content
Snippets Groups Projects
Commit 9e7607fa authored by Brett McAndrew's avatar Brett McAndrew
Browse files

Merge branch '1-fix-assignment-errors' into 'main'

Unit tests added

Closes #1

See merge request !1
parents f4cc147e b9ff1f22
No related branches found
No related tags found
1 merge request!1Unit tests added
......@@ -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 boxCompleteDetectsCompletedBoxes() {
// A grid where we're going to draw a box, and then test whether it's complete
DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2);
case1.drawHorizontal(0, 0, 0);
case1.drawVertical(0, 0, 1);
case1.drawHorizontal(0, 1, 0);
case1.drawVertical(1, 0, 1);
assertTrue(case1.boxComplete(0, 0));
assertTrue(case1.boxComplete(1, 1));
assertTrue(case1.getHorizontal(0, 0)&&case1.getVertical(0, 0));
assertTrue(case1.getHorizontal(1, 0)&&case1.getVertical(1, 0));
}
@Test
public void drawHorizontalTest() {
DotsAndBoxesGrid case1 = new DotsAndBoxesGrid(5, 5, 2);
case1.drawHorizontal(0, 0, 0);
case1.drawVertical(0, 0, 1);
case1.drawHorizontal(0, 1, 0);
case1.drawVertical(1, 0, 1);
assertThrows(RuntimeException.class, () -> {case1.drawHorizontal(0, 0, 0);});
}
}
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