Skip to content
Snippets Groups Projects

Unit tests added

Merged Brett McAndrew requested to merge 1-fix-assignment-errors into main
1 file
+ 26
1
Compare changes
  • Side-by-side
  • Inline
@@ -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);});
}
}
Loading