Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dots-and-boxes-carol-ann
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
Carol-Ann Donaldson
dots-and-boxes-carol-ann
Commits
2a54e73e
Commit
2a54e73e
authored
11 months ago
by
Carol-Ann Donaldson
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests to detect assignment errors - square completion and drawing lines twice
parent
3f9f831d
No related branches found
No related tags found
1 merge request
!1
Resolve "Fix assignment errors"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+25
-1
25 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
25 additions
and
1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
25
−
1
View file @
2a54e73e
...
...
@@ -26,6 +26,30 @@ public class DotsAndBoxesGridTest {
logger
.
info
(
"Dummy test to show the test suite runs"
);
assertTrue
(
true
);
}
@Test
public
void
testSquareCompletion
()
{
logger
.
info
(
"Testing if square completion detection is working"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
);
// Simulate drawing lines to complete a square at (0,0)
grid
.
drawHorizontal
(
0
,
0
,
1
);
grid
.
drawVertical
(
0
,
0
,
1
);
grid
.
drawHorizontal
(
0
,
1
,
1
);
grid
.
drawVertical
(
1
,
0
,
1
);
// The square at (0,0) should be complete
assertTrue
(
grid
.
isSquareComplete
(
0
,
0
),
"Square at (0,0) should be complete"
);
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testDrawingLineTwiceThrowsException
()
{
logger
.
info
(
"Testing if drawing a line twice throws an IllegalStateException"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
);
// Simulate drawing a horizontal line
grid
.
drawHorizontal
(
0
,
0
,
1
);
// Try drawing the same horizontal line again, which should throw an IllegalStateException
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawHorizontal
(
0
,
0
,
1
));
}
}
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