Skip to content
Snippets Groups Projects
Commit 351ab749 authored by saryal3's avatar saryal3
Browse files

Added failing unit tests for known bugs in square completion and duplicate line draw

parent aea174d6
Branches
No related merge requests found
...@@ -20,12 +20,30 @@ public class DotsAndBoxesGridTest { ...@@ -20,12 +20,30 @@ public class DotsAndBoxesGridTest {
* or more assertions to check that a condition holds. * or more assertions to check that a condition holds.
* *
* This is a dummy test just to show that the test suite itself runs * This is a dummy test just to show that the test suite itself runs
* Following are the Unit testing done
*/ */
@Test @Test
public void testTestSuiteRuns() { public void testIncompleteSquare() {
logger.info("Dummy test to show the test suite runs"); DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); // Create a 3x3 grid
assertTrue(true);
// Mark only two lines of a square (incomplete)
grid.drawHorizontal(0, 0, 1);
grid.drawVertical(0, 1, 1);
// Assert that the square is not complete
assertFalse(grid.boxComplete(0, 0), "Square should not be complete with only two lines");
} }
// FIXME: You need to write tests for the two known bugs in the code. @Test
public void testDuplicateLineDrawing() {
DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2); // Create a 3x3 grid
// Mark a horizontal line
grid.drawHorizontal(0, 0, 1);
// Attempt to draw the same line again
assertThrows(IllegalStateException.class, () -> grid.drawHorizontal(0, 0, 1),
"Duplicate line drawing should throw an IllegalStateException");
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment