Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COSC220 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mhay23
COSC220 Assessment 2
Commits
aee39a57
Commit
aee39a57
authored
3 years ago
by
mhay23
Browse files
Options
Downloads
Patches
Plain Diff
Wrote unit tests for known bugs
parent
07df38de
No related branches found
No related tags found
No related merge requests found
Pipeline
#1412
failed
3 years ago
Stage: build
Stage: test
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+43
-0
43 additions, 0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
43 additions
and
0 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
43
−
0
View file @
aee39a57
...
...
@@ -13,6 +13,18 @@ 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
);
public
static
DotsAndBoxesGrid
grid
;
@BeforeAll
public
static
void
beforeAll
(){
logger
.
info
(
"Running 'before all' setup"
);
}
@BeforeEach
public
void
beforeEach
(){
logger
.
info
(
"Running 'before each' setup"
);
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
}
/*
* Tests are functions that have an @Test annotation before them.
...
...
@@ -28,4 +40,35 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testBoxIsComplete
()
{
logger
.
info
(
"Checking completed box is correctly detected"
);
//empty grid, test top left box
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
//draw top horizontal and test
grid
.
drawHorizontal
(
0
,
0
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
//draw left vertical and test
grid
.
drawVertical
(
0
,
0
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
//draw bottom horizontal and test
grid
.
drawHorizontal
(
0
,
1
,
1
);
assertFalse
(
grid
.
boxComplete
(
0
,
0
));
//draw right vertical and test, box now complete
grid
.
drawVertical
(
1
,
0
,
1
);
assertTrue
(
grid
.
boxComplete
(
0
,
0
));
}
@Test
public
void
testCantRedrawLine
(){
//draw line first time
grid
.
drawHorizontal
(
0
,
0
,
1
);
assertThrows
(
IllegalStateException
.
class
,
()
->
grid
.
drawHorizontal
(
0
,
0
,
2
));
}
}
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