Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dotandbox
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
Naba Khan
dotandbox
Commits
69cd737b
Commit
69cd737b
authored
11 months ago
by
Will Billingsley
Browse files
Options
Downloads
Patches
Plain Diff
Added Unit Tests
parent
122b79c0
Branches
Branches containing commit
Tags
testsfail
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+67
-1
67 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
67 additions
and
1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
67
−
1
View file @
69cd737b
...
...
@@ -2,7 +2,6 @@ package dotsandboxes;
import
org.junit.jupiter.api.*
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.*;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -28,4 +27,71 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testDrawHorizontalLineTwiceThrowsException
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawHorizontal
(
0
,
0
,
1
);
});
String
expectedMessage
=
"Line has already been drawn"
;
String
actualMessage
=
exception
.
getMessage
();
assertTrue
(
actualMessage
.
contains
(
expectedMessage
),
"Expected an IllegalStateException for drawing a line that was already drawn"
);
}
@Test
public
void
testDrawVerticalLineTwiceThrowsException
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
grid
.
drawVertical
(
0
,
0
,
1
);
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawVertical
(
0
,
0
,
1
);
});
String
expectedMessage
=
"Line has already been drawn"
;
String
actualMessage
=
exception
.
getMessage
();
assertTrue
(
actualMessage
.
contains
(
expectedMessage
),
"Expected an IllegalStateException for drawing a line that was already drawn"
);
}
@Test
public
void
testBoxIncompleteAtLeftEdge
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// Draw three lines around the box at (0,1)
grid
.
drawHorizontal
(
0
,
1
,
1
);
grid
.
drawHorizontal
(
0
,
2
,
1
);
grid
.
drawVertical
(
0
,
1
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
1
),
"The box at (0,1) should not be complete with only three lines drawn"
);
}
@Test
public
void
testBoxIncomplete
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// Draw only one horizontal line
grid
.
drawHorizontal
(
0
,
0
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"The box at (0,0) should not be complete with only one line drawn"
);
// Draw two lines (horizontal and vertical)
grid
.
drawVertical
(
0
,
0
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"The box at (0,0) should not be complete with only two lines drawn"
);
// Draw three lines
grid
.
drawHorizontal
(
0
,
1
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
),
"The box at (0,0) should not be complete with only three lines 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