Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cosc220 Assessment 2 Jason Aboh
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
Jason Aboh
Cosc220 Assessment 2 Jason Aboh
Commits
3fc75196
Commit
3fc75196
authored
3 years ago
by
Jason Aboh
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests to test for the two known bug issues
parent
21343e09
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+54
-0
54 additions, 0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
54 additions
and
0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
54
−
0
View file @
3fc75196
...
...
@@ -28,4 +28,58 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
// Test to check for box completion , if it has 4 lines drawn then it is complete, else it is incomplete.
@Test
public
void
testForBoxCompletion
(){
logger
.
info
(
"Testing to check that a box is fully drawn, only when it is complete"
);
// Create new grid
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
2
,
2
,
1
);
// Check for empty box
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"Empty box is incomplete and should not be claimable"
);
// Draw vertical line
grid
.
drawVertical
(
0
,
0
,
1
);
// Box is incomplete
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"Box is incomplete and should not be claimable"
);
// Draw a horizontal line
grid
.
drawHorizontal
(
0
,
0
,
1
);
// Box is incomplete
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"Box is incomplete and should not be claimable"
);
// Draw another vertical line and another horizontal line to complete the box
grid
.
drawVertical
(
1
,
0
,
1
);
grid
.
drawHorizontal
(
0
,
1
,
1
);
// Check for complete box
assertTrue
(
grid
.
boxComplete
(
0
,
0
),
"Box is complete and should be fully drawn and claimable"
);
}
// Test to check if a line can be drawn, and to throw an illegalStateException if the line has already been
// drawn at the same coordinates (duplicate).
@Test
public
void
TestForDuplicateLinesDrawn
(){
logger
.
info
(
"Testing to check that it is disallowed to draw over a line that has already been drawn"
);
// Create new grid
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
2
,
2
,
1
);
// Test to check if a vertical and horizontal line can be drawn to the grid
assertFalse
(
grid
.
drawVertical
(
0
,
0
,
1
));
assertFalse
(
grid
.
drawHorizontal
(
0
,
0
,
1
));
// Test to catch IllegalStateException, when a duplicate vertical line draw attempt is made
// at the same coordinates.
assertThrows
(
IllegalStateException
.
class
,()->
grid
.
drawVertical
(
0
,
0
,
1
)
,
"This line has already been drawn"
);
// Test to catch IllegalStateException, when a duplicate horizontal line draw attempt is made
// at the same coordinates.
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawHorizontal
(
0
,
0
,
1
),
"This line has already been drawn"
);
}
}
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