Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Assessment 2
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
atravain
Assessment 2
Commits
3ae346ba
Commit
3ae346ba
authored
3 years ago
by
atravain
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests to perform checks on known bugs, These tests currently fail
parent
3473d067
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+36
-1
36 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
36 additions
and
1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
36
−
1
View file @
3ae346ba
...
...
@@ -27,5 +27,40 @@ public class DotsAndBoxesGridTest {
assertTrue
(
true
);
}
// FIXME: You need to write tests for the two known bugs in the code.
// A test to check that the boxComplete function performs correctly
@Test
public
void
testBoxComplete
()
{
// Creates a grid with a box starting at (0,0)
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
);
logger
.
info
(
"This test checks that the boxComplete function works correctly"
);
assertAll
(
"A complete box must return true, an incomplete must return false."
,
()
->
assertTrue
(
grid
.
boxComplete
(
0
,
0
)),
// Returns false as the x,y co-ordinates passed are not the left and top co-ordinates of the box
()
->
assertFalse
(
grid
.
boxComplete
(
1
,
1
))
);
}
// A test to check that the program throws an exception when a player attempts to draw a line in a position that
// has already been played
@Test
public
void
testDrawLine
()
{
// Creates a grid and draws a horizontal and vertical line at (0,0)
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
grid
.
drawVertical
(
0
,
0
,
1
);
logger
.
info
(
"This test checks that an exception is thrown when a player tries to draw a line that is already drawn"
);
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawHorizontal
(
0
,
0
,
1
),
"The horizontal line was drawn more than once"
);
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawVertical
(
0
,
0
,
1
),
"The vertical line was drawn more than once"
);
}
}
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