From e2a2aa46a467d376688f65bd17145f1484ef3e88 Mon Sep 17 00:00:00 2001
From: Padinharayil Anoop <panoop@myune.edu.au>
Date: Wed, 2 Aug 2023 14:51:24 +1000
Subject: [PATCH] Add failing unit tests for assignment errors.

---
 .../dotsandboxes/DotsAndBoxesGridTest.java    | 27 ++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
index 1946bed..851da9b 100644
--- a/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+++ b/src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
@@ -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 testSquareCompletion() {
+    DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
+
+    // Draw only three lines of a box
+    grid.drawHorizontal(0, 0, 1);
+    grid.drawVertical(0, 0, 1);
+    grid.drawVertical(1, 0, 1);
+
+    // Check if the box is indeed incomplete
+    assertFalse(grid.boxComplete(0, 0));
+}
+
+@Test
+public void testDrawExistingLine() {
+    DotsAndBoxesGrid grid = new DotsAndBoxesGrid(3, 3, 2);
+
+    // Draw a line
+    grid.drawHorizontal(0, 0, 1);
+
+    // Attempt to draw the same line again. This should throw an IllegalStateException.
+    assertThrows(IllegalStateException.class, () -> {
+        grid.drawHorizontal(0, 0, 1);
+    });
+}
+
 }
-- 
GitLab