Commit 0ab1d2db authored by rbirch4's avatar rbirch4
Browse files

Fully fixed all unit tests and confirmed that they run correctly but fail due...

Fully fixed all unit tests and confirmed that they run correctly but fail due to the bugs in DotsAndBoxesGrid.java. Tidied them up with no hard-coded values in eaach method.
parent b95bef24
......@@ -2,7 +2,7 @@ package dotsandboxes;
import org.junit.jupiter.api.*;
import jdk.jfr.Timestamp;
//import jdk.jfr.Timestamp;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
......@@ -43,10 +43,11 @@ public class DotsAndBoxesGridTest {
//Imagine that only a single arbitrary line exists on a dots and boxes grid of any size. Then, we know for sure that the box has not been drawn and
//should return false. Not dependent on a dots and boxes object existing as method is recursively called when "drawing" a line but is not yet complete.
int knownIncompleteX = 1;
int knownIncompleteY = 2;
int knownIncompleteY = 1;
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean incompleteBox = test3by3.drawHorizontal(knownIncompleteX, knownIncompleteY, 1);
boolean boxCompleteResult = test3by3.boxComplete(knownIncompleteX, knownIncompleteY);
logger.info(boxCompleteResult);
assertFalse(boxCompleteResult);
}
......@@ -56,22 +57,25 @@ public class DotsAndBoxesGridTest {
//Create an example player.
//Draw a horizontal line from 1, 2 to 2,2.
//Draw the above line again and assert that it throws an IllegalStateException.
int horzX = 1;
int horzY = 2;
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = test3by3.drawHorizontal(1, 2, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawHorizontal(1, 2, 1));
boolean initialLine = test3by3.drawHorizontal(horzX, horzY, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawHorizontal(horzX, horzY, 1));
}
@Test
public void testNoDrawOverwriteVert() {
//Create a dots and boxes grid - a 3x3 will do.
//Create an example player.
//Draw a horizontal line from 1, 2 to 2,2.
//Draw the above line again and assert that it throws an IllegalStateException.
int vertX = 1;
int vertY = 1;
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = test3by3.drawVertical(3, 1, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawVertical(3, 1, 1));
boolean initialLine = test3by3.drawVertical(vertX, vertY, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawVertical(vertX, vertY, 1));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment