Skip to content
Snippets Groups Projects
Commit a63fb852 authored by Curtis James Moore's avatar Curtis James Moore
Browse files

Added tests to check if horizontal and vertical lines are appropriately drawn....

Added tests to check if horizontal and vertical lines are appropriately drawn. Also added test to check if boxComplete correctly checks if a box is complete
parent e97316fb
No related branches found
No related tags found
No related merge requests found
.DS_Store 0 → 100644
File added
......@@ -26,6 +26,68 @@ public class DotsAndBoxesGridTest {
logger.info("Dummy test to show the test suite runs");
assertTrue(true);
}
@Test
public void testBoxCompleteFalse() {
//Creating a box that should be incorrect and checking if it returns false
DotsAndBoxesGrid boxCompleteFalse = new DotsAndBoxesGrid(5, 5, 2);
boxCompleteFalse.drawHorizontal(0, 0, 0);
boxCompleteFalse.drawVertical(0, 0, 1);
boxCompleteFalse.drawHorizontal(0, 1, 0);
boxCompleteFalse.drawVertical(1, 1, 1);
assertFalse(boxCompleteFalse.boxComplete(0, 0));
}
@Test
public void testBoxCompleteTrue() {
//Creating a box that should be correct and checking if it returns true
DotsAndBoxesGrid boxCompleteTrue = new DotsAndBoxesGrid(5, 5, 2);
boxCompleteTrue.drawHorizontal(0, 0, 0);
boxCompleteTrue.drawVertical(0, 0, 1);
boxCompleteTrue.drawHorizontal(0, 1, 0);
boxCompleteTrue.drawVertical(1, 0, 1);
assertTrue(boxCompleteTrue.boxComplete(0, 0));
}
@Test
public void testDrawHorizontalDrawn() {
//Draws a horizontal line, then draws another horizontal line in the same
//place to check if an exception is appropriately thrown
DotsAndBoxesGrid horizontalDrawn = new DotsAndBoxesGrid(5, 5, 1);
horizontalDrawn.drawHorizontal(0, 0, 1);
assertThrows(RuntimeException.class, () -> {
horizontalDrawn.drawHorizontal(0, 0, 1);
});
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public void testDrawHorizontalNotDrawn() {
//Draws a horizontal line to check if no exception is thrown
DotsAndBoxesGrid horizontalNotDrawn = new DotsAndBoxesGrid(5, 5, 1);
assertDoesNotThrow(() -> {
horizontalNotDrawn.drawHorizontal(0, 0, 1);
});
}
@Test
public void testDrawVerticalDrawn() {
//Draws a vertical line, then draws another vertical line in the same
//place to check if an exception is appropriately thrown
DotsAndBoxesGrid verticalDrawn = new DotsAndBoxesGrid(5, 5, 1);
verticalDrawn.drawVertical(0, 0, 1);
assertThrows(RuntimeException.class, () -> {
verticalDrawn.drawVertical(0, 0, 1);
});
}
@Test
public void testDrawVerticalNotDrawn() {
//Draws a vertical line to check if no exception is thrown
DotsAndBoxesGrid verticalNotDrawn = new DotsAndBoxesGrid(5, 5, 1);
assertDoesNotThrow(() -> {
verticalNotDrawn.drawVertical(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