Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
rbirch4
rbirch4_cosc220_a2
Commits
b95bef24
Commit
b95bef24
authored
Jul 15, 2021
by
rbirch4
Browse files
Fix attempt on my buggy unit tests. Pending actual run though, but progress has been made.
parent
2f3a6d78
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/dotsandboxes/DotsAndBoxesGrid.java
View file @
b95bef24
...
...
@@ -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.
...
...
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
View file @
b95bef24
...
...
@@ -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
)
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment