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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scott Crooks
Assessment 2
Merge requests
!1
Resolve "Fix errors in assignment"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "Fix errors in assignment"
1-fix-errors-in-assignment
into
main
Overview
0
Commits
2
Pipelines
0
Changes
1
Merged
Scott Crooks
requested to merge
1-fix-errors-in-assignment
into
main
11 months ago
Overview
0
Commits
2
Pipelines
0
Changes
1
Closes
#1 (closed)
0
0
Merge request reports
Viewing commit
88c938c4
Prev
Next
Show latest version
1 file
+
56
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
88c938c4
Implemented tests for boxComplete and drawVertical/Horizontal
· 88c938c4
Scott Crooks
authored
11 months ago
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
56
−
0
View file @ 88c938c4
Edit in single-file editor
Open in Web IDE
Show full file
@@ -28,4 +28,60 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testBoxCompleteFull
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
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
));
}
@Test
public
void
testBoxCompletePartial
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
grid
.
drawHorizontal
(
1
,
1
,
1
);
grid
.
drawVertical
(
1
,
1
,
1
);
grid
.
drawVertical
(
2
,
1
,
1
);
assertFalse
(
grid
.
boxComplete
(
1
,
1
));
}
@Test
public
void
testDrawVerticalOnce
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
assertFalse
(
grid
.
drawVertical
(
1
,
1
,
1
));
}
@Test
public
void
testVerticalCannotBeRedrawn
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
grid
.
drawVertical
(
1
,
1
,
1
);
Exception
exception
=
assertThrows
(
IllegalArgumentException
.
class
,
()
->
{
grid
.
drawVertical
(
1
,
1
,
2
);
});
assertTrue
(
exception
instanceof
IllegalArgumentException
);
}
@Test
public
void
testDrawHorizontalOnce
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
assertFalse
(
grid
.
drawHorizontal
(
1
,
1
,
1
));
}
@Test
public
void
testHorizontalCannotBeRedrawn
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
grid
.
drawHorizontal
(
1
,
1
,
1
);
Exception
exception
=
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawHorizontal
(
1
,
1
,
2
);
});
assertTrue
(
exception
instanceof
IllegalArgumentException
);
}
}
Loading