Commit b95bef24 authored by rbirch4's avatar rbirch4
Browse files

Fix attempt on my buggy unit tests. Pending actual run though, but progress has been made.

parent 2f3a6d78
......@@ -111,7 +111,7 @@ public class DotsAndBoxesGrid {
if (x >= width - 1 || x < 0 || y >= height - 1 || y < 0) {
return false;
}
// A box is complete if the north and south horizontals and the east and west verticals have all been drawn.
// FIXME: You'll need to fix this code (after writing a test first).
//Return true if box complete, false if not.
......
......@@ -44,7 +44,9 @@ public class DotsAndBoxesGridTest {
//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;
boolean boxCompleteResult = boxComplete(knownIncompleteX, knownIncompleteY);
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean incompleteBox = test3by3.drawHorizontal(knownIncompleteX, knownIncompleteY, 1);
boolean boxCompleteResult = test3by3.boxComplete(knownIncompleteX, knownIncompleteY);
assertFalse(boxCompleteResult);
}
......@@ -55,9 +57,9 @@ public class DotsAndBoxesGridTest {
//Draw a horizontal line from 1, 2 to 2,2.
//Draw the above line again and assert that it throws an IllegalStateException.
DotsAndBoxesGrid test3by3 = DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = drawHorizontal(1, 2, 1);
assertThrows(sameLine = drawHorizontal(1, 2, 1), IllegalStateException);
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = test3by3.drawHorizontal(1, 2, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawHorizontal(1, 2, 1));
}
......@@ -67,9 +69,9 @@ public class DotsAndBoxesGridTest {
//Draw a horizontal line from 1, 2 to 2,2.
//Draw the above line again and assert that it throws an IllegalStateException.
DotsAndBoxesGrid test3by3 = DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = drawVertical(3, 1, 1);
assertThrows(sameLine = drawHorizontal(3, 1, 1), IllegalStateException);
DotsAndBoxesGrid test3by3 = new DotsAndBoxesGrid(3, 3, 1);
boolean initialLine = test3by3.drawVertical(3, 1, 1);
assertThrows(IllegalStateException.class,() -> test3by3.drawVertical(3, 1, 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