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
Martin Schreiber
COSC220 A2
Commits
de4783d4
Commit
de4783d4
authored
Jul 22, 2021
by
Martin Schreiber
Browse files
added unit tests for issue
#1
parent
9dcdc67e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
View file @
de4783d4
...
...
@@ -21,11 +21,60 @@ public class DotsAndBoxesGridTest {
*
* This is a dummy test just to show that the test suite itself runs
*/
@Test
public
void
testTestSuiteRuns
()
{
logger
.
info
(
"Dummy test to show the test suite runs"
);
assertTrue
(
true
);
}
@Test
public
void
noLinesDrawnTest
()
{
logger
.
error
(
"Test whether boxComplete shows false with no lines drawn"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
}
@Test
public
void
oneLineTest
()
{
logger
.
error
(
"Test whether boxComplete shows false with one line on each side drawn"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
grid
.
drawVertical
(
0
,
0
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
}
@Test
public
void
completeBoxTest
()
{
logger
.
error
(
"Test whether boxComplete shows true with whole box"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
grid
.
drawHorizontal
(
0
,
1
,
1
);
grid
.
drawVertical
(
0
,
0
,
1
);
grid
.
drawVertical
(
1
,
0
,
1
);
assertTrue
(
grid
.
boxComplete
(
0
,
0
));
}
@Test
public
void
horizontalReDrawTest
()
{
logger
.
error
(
"Test whether drawHorizontal throws exception if line is already present"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
assertThrows
(
RuntimeException
.
class
,
()
->
grid
.
boxComplete
(
0
,
0
));
}
@Test
public
void
verticalReDrawTest
()
{
logger
.
error
(
"Test whether drawHorizontal throws exception if line is already present"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
grid
.
drawVertical
(
0
,
0
,
1
);
assertThrows
(
RuntimeException
.
class
,
()
->
grid
.
drawVertical
(
0
,
0
,
1
));
}
// FIXME: You need to write tests for the two known bugs in the code.
}
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