Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dots And boxes
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
Vinay Kumar Yendala
dots And boxes
Commits
79cd9035
Commit
79cd9035
authored
11 months ago
by
Will Billingsley
Browse files
Options
Downloads
Patches
Plain Diff
Add failing unit tests to highlight known bugs in DotsAndBoxesGrid
parent
8e4e51b2
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
+35
-1
35 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
35 additions
and
1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
35
−
1
View file @
79cd9035
...
...
@@ -13,6 +13,7 @@ public class DotsAndBoxesGridTest {
* This field is a logger. Loggers are like a more advanced println, for writing messages out to the console or a log file.
*/
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
DotsAndBoxesGridTest
.
class
);
private
DotsAndBoxesGrid
grid
;
/*
* Tests are functions that have an @Test annotation before them.
...
...
@@ -27,5 +28,38 @@ public class DotsAndBoxesGridTest {
assertTrue
(
true
);
}
// FIXME: You need to write tests for the two known bugs in the code.
@BeforeEach
public
void
setup
()
{
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// Assuming a 3x3 grid with 2 players
}
@Test
public
void
testBoxNotCompleteInitially
()
{
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"Box should not be complete without any lines drawn."
);
}
@Test
public
void
testCompleteBox
()
{
// Draw all four lines around a single box
grid
.
drawHorizontal
(
0
,
0
,
1
);
grid
.
drawHorizontal
(
0
,
1
,
1
);
grid
.
drawVertical
(
0
,
0
,
1
);
grid
.
drawVertical
(
1
,
0
,
1
);
assertTrue
(
grid
.
boxComplete
(
0
,
0
),
"Box at (0, 0) should be complete."
);
}
@Test
public
void
testRedrawingHorizontalLineThrowsException
()
{
grid
.
drawHorizontal
(
0
,
0
,
1
);
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawHorizontal
(
0
,
0
,
1
));
assertEquals
(
"Line already drawn."
,
exception
.
getMessage
(),
"Should throw an exception when redrawing a horizontal line."
);
}
@Test
public
void
testRedrawingVerticalLineThrowsException
()
{
grid
.
drawVertical
(
0
,
0
,
1
);
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawVertical
(
0
,
0
,
1
));
assertEquals
(
"Line already drawn."
,
exception
.
getMessage
(),
"Should throw an exception when redrawing a vertical line."
);
}
}
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