Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DotsAndBoxes
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atom3
DotsAndBoxes
Commits
fc89506b
Commit
fc89506b
authored
11 months ago
by
Will Billingsley
Browse files
Options
Downloads
Patches
Plain Diff
Added test units to detect the errors
parent
e6f6f37a
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
+38
-0
38 additions, 0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
38 additions
and
0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
38
−
0
View file @
fc89506b
...
...
@@ -27,5 +27,43 @@ public class DotsAndBoxesGridTest {
assertTrue
(
true
);
}
@Test
public
void
testBoxComplete
(){
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
4
,
4
,
2
);
//Drawing lines
grid
.
drawHorizontal
(
1
,
1
,
1
);
grid
.
drawHorizontal
(
1
,
2
,
1
);
grid
.
drawVertical
(
1
,
1
,
1
);
grid
.
drawVertical
(
2
,
1
,
1
);
//The box
assertTrue
(
grid
.
BoxComplete
(
1
,
1
));
}
@Test
public
void
testDrawAlreadyDrawnLine
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
4
,
4
,
2
);
// Drawing a horizontal line at (1, 1)
grid
.
drawHorizontal
(
1
,
1
,
1
);
// Attempting to draw the same horizontal line again should throw an IllegalStateException
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawHorizontal
(
1
,
1
,
1
);
});
assertEquals
(
"Horizontal line at (1, 1) is already drawn."
,
exception
.
getMessage
());
// Drawing a vertical line at (1, 1)
grid
.
drawVertical
(
1
,
1
,
1
);
// Attempting to draw the same vertical line again should throw an IllegalStateException
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawVertical
(
1
,
1
,
1
);
});
assertEquals
(
"Vertical line at (1, 1) is already drawn."
,
exception
.
getMessage
());
}
// FIXME: You need to write tests for the two known bugs in the code.
}
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