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
dc5b18f6
Commit
dc5b18f6
authored
Jul 20, 2024
by
Carol-Ann Donaldson
Browse files
Options
Downloads
Plain Diff
Merge branch '1-fix-assignment-errors' into 'main'
Resolve "Fix assignment errors" Closes
#1
See merge request
!1
parents
3f9f831d
60f6a15f
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
+32
-15
32 additions, 15 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
32 additions
and
15 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
32
−
15
View file @
dc5b18f6
package
dotsandboxes
;
package
dotsandboxes
;
import
org.junit.jupiter.api.
*
;
import
org.junit.jupiter.api.
Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
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.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
public
class
DotsAndBoxesGridTest
{
public
class
DotsAndBoxesGridTest
{
/*
* Because Test classes are classes, they can have fields, and can have static fields.
* 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
static
final
Logger
logger
=
LogManager
.
getLogger
(
DotsAndBoxesGridTest
.
class
);
/*
* Tests are functions that have an @Test annotation before them.
* The typical format of a test is that it contains some code that does something, and then one
* or more assertions to check that a condition holds.
*
* This is a dummy test just to show that the test suite itself runs
*/
@Test
@Test
public
void
testTestSuiteRuns
()
{
public
void
testTestSuiteRuns
()
{
logger
.
info
(
"Dummy test to show the test suite runs"
);
logger
.
info
(
"Dummy test to show the test suite runs"
);
assertTrue
(
true
);
assertTrue
(
true
);
}
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testSquareCompletion
()
{
logger
.
info
(
"Testing if square completion detection is working"
);
// Initialize the grid with dimensions and number of players
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// 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
);
// Check if the square at (0,0) is complete
assertTrue
(
grid
.
boxComplete
(
0
,
0
),
"Square at (0,0) should be complete"
);
}
}
@Test
public
void
testDrawingLineTwiceThrowsException
()
{
logger
.
info
(
"Testing if drawing a line twice throws an IllegalStateException"
);
// Initialize the grid with dimensions and number of players
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
3
,
3
,
2
);
// 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