Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Game of life Toullec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
TOULLEC Romain
Game of life Toullec
Commits
0b05b409
Commit
0b05b409
authored
3 years ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
Tests changés pour utiliser setAlive de CellState
parent
48a1a068
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/model/Cell.java
+9
-0
9 additions, 0 deletions
src/main/java/model/Cell.java
src/test/java/model/GridTest.java
+32
-20
32 additions, 20 deletions
src/test/java/model/GridTest.java
with
41 additions
and
20 deletions
src/main/java/model/Cell.java
+
9
−
0
View file @
0b05b409
...
@@ -30,6 +30,15 @@ public class Cell {
...
@@ -30,6 +30,15 @@ public class Cell {
getStateProperty
().
setValue
(
cellState
);
getStateProperty
().
setValue
(
cellState
);
}
}
/**
* Sets the state of this {@link Cell} to an arbitrary alive state.
*/
public
void
setAlive
()
{
getStateProperty
().
setValue
(
CellState
.
ALIVE
);
}
/**
/**
* Returns the current state of this {@link Cell}.
* Returns the current state of this {@link Cell}.
*
*
...
...
This diff is collapsed.
Click to expand it.
src/test/java/model/GridTest.java
+
32
−
20
View file @
0b05b409
...
@@ -9,30 +9,42 @@ public class GridTest {
...
@@ -9,30 +9,42 @@ public class GridTest {
private
Grid
grid
;
private
Grid
grid
;
@BeforeEach
@BeforeEach
public
void
initializeGrid
(){
public
void
initializeGrid
()
{
grid
=
new
Grid
(
3
,
3
);
grid
=
new
Grid
(
6
,
6
);
}
}
@Test
@Test
public
void
testGetNeighbors
(){
public
void
testGetNeighbo
u
rs
()
{
assertThat
(
grid
.
getNeighbors
(
1
,
1
)).
isNotNull
();
assertThat
(
grid
.
getNeighbors
(
1
,
1
)).
isNotNull
();
assertThat
(
grid
.
getNeighbors
(
1
,
1
)).
hasSize
(
8
);
assertThat
(
grid
.
getNeighbors
(
1
,
1
)).
hasSize
(
8
);
assertThat
(
grid
.
getNeighbors
(
1
,
1
))
assertThat
(
grid
.
getNeighbors
(
1
,
1
))
.
containsExactlyInAnyOrder
(
grid
.
getCell
(
0
,
0
),
.
containsExactlyInAnyOrder
(
grid
.
getCell
(
0
,
0
),
grid
.
getCell
(
0
,
1
),
grid
.
getCell
(
0
,
1
),
grid
.
getCell
(
0
,
2
),
grid
.
getCell
(
0
,
2
),
grid
.
getCell
(
1
,
0
),
grid
.
getCell
(
1
,
0
),
grid
.
getCell
(
1
,
2
),
grid
.
getCell
(
1
,
2
),
grid
.
getCell
(
2
,
0
),
grid
.
getCell
(
2
,
0
),
grid
.
getCell
(
2
,
1
),
grid
.
getCell
(
2
,
1
),
grid
.
getCell
(
2
,
2
));
grid
.
getCell
(
2
,
2
));
}
}
@Test
@Test
public
void
testCountAliveNeighbors
(){
public
void
testCountAliveNeighbo
u
rs
()
{
assertThat
(
grid
.
countAliveNeighbors
(
1
,
1
)).
isEqualTo
(
0
);
assertThat
(
grid
.
countAliveNeighbors
(
1
,
1
)).
isEqualTo
(
0
);
grid
.
getCell
(
2
,
2
).
set
State
(
CellState
.
ALIVE
);
grid
.
getCell
(
2
,
2
).
set
Alive
(
);
grid
.
getCell
(
0
,
0
).
set
State
(
CellState
.
ALIVE
);
grid
.
getCell
(
0
,
0
).
set
Alive
(
);
assertThat
(
grid
.
countAliveNeighbors
(
1
,
1
)).
isEqualTo
(
2
);
assertThat
(
grid
.
countAliveNeighbors
(
1
,
1
)).
isEqualTo
(
2
);
}
}
}
@Test
public
void
testCalculateNextState
()
{
grid
.
getCell
(
1
,
0
).
setAlive
();
grid
.
getCell
(
1
,
1
).
setAlive
();
grid
.
getCell
(
1
,
2
).
setAlive
();
assertThat
(
grid
.
calculateNextState
(
0
,
0
).
isAlive
).
isFalse
();
assertThat
(
grid
.
calculateNextState
(
1
,
0
).
isAlive
).
isFalse
();
assertThat
(
grid
.
calculateNextState
(
1
,
1
).
isAlive
).
isTrue
();
assertThat
(
grid
.
calculateNextState
(
2
,
1
).
isAlive
).
isTrue
();
}
}
\ No newline at end of file
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