Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cosc220_a2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hayden James Swift
cosc220_a2
Commits
649cf71c
Commit
649cf71c
authored
8 months ago
by
Hayden James Swift
Browse files
Options
Downloads
Patches
Plain Diff
Implemented testing functions to DotsAndBoxesGridTest.java
parent
f4f0b8f1
No related branches found
Branches containing commit
Tags
testsfail
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+65
-1
65 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
65 additions
and
1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
65
−
1
View file @
649cf71c
...
...
@@ -27,5 +27,69 @@ public class DotsAndBoxesGridTest {
assertTrue
(
true
);
}
// FIXME: You need to write tests for the two known bugs in the code.
/*
* This tests the boxComplete() function.
*/
@Test
public
void
testForBoxComplete
()
{
logger
.
info
(
"Testing if box is complete."
);
// Create new grid instance
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// Draw half a box
grid
.
drawVertical
(
1
,
1
,
1
);
grid
.
drawVertical
(
2
,
1
,
1
);
// Test boxComplete() function
assertFalse
(
grid
.
boxComplete
(
1
,
1
));
// Draw remaining lines
grid
.
drawHorizontal
(
1
,
1
,
1
);
grid
.
drawHorizontal
(
1
,
2
,
1
);
// Test boxComplete() function
assertTrue
(
grid
.
boxComplete
(
1
,
1
));
}
/*
* Test for drawHorizontal() function.
*/
@Test
public
void
testDrawHorizontal
()
{
logger
.
info
(
"Testing drawHorizontal()"
);
// Initialise new DotsAndBoxesGrid instance and new player
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
int
player
=
1
;
// Draw new line at (1, 1). This should return false as the box is not complete.
assertFalse
(
grid
.
drawHorizontal
(
1
,
1
,
player
));
// Try redraw line at (1, 1). This should throw an IllegalStateException.
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawHorizontal
(
1
,
1
,
player
);
});
}
/*
* Test for drawVertical() function.
*/
@Test
public
void
testDrawVertical
()
{
logger
.
info
(
"Testing drawVertical()"
);
// Initialise new DotsAndBoxesGrid instance and new player
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
int
player
=
1
;
// Draw new line at (1, 1). This should return false as the box is not complete.
assertFalse
(
grid
.
drawVertical
(
1
,
1
,
player
));
// Try redraw line at (1, 1). This should throw an IllegalStateException.
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawVertical
(
1
,
1
,
player
);
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment