Skip to content
Snippets Groups Projects
Commit 15ab66ec authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

Passage à AssertJ

parent 08632686
Branches
Tags
No related merge requests found
......@@ -13,9 +13,9 @@ repositories {
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.2',
'org.hamcrest:hamcrest-library:2.2', 'net.obvj:junit-utils:1.3.1')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.0',
'org.assertj:assertj-core:3.20.2')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'
}
test {
......
......@@ -90,12 +90,12 @@ public class Grid implements Iterable<Cell> {
// TODO: Écrire une version correcte de cette méthode.
public List<Cell> getNeighbours(int rowIndex, int columnIndex) {
public List<Cell> getNeighbors(int rowIndex, int columnIndex) {
return null;
}
// TODO: Écrire une version correcte de cette méthode.
public int countAliveNeighbours(int rowIndex, int columnIndex) {
public int countAliveNeighbors(int rowIndex, int columnIndex) {
return 0;
}
......
......@@ -2,8 +2,8 @@ package model;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.assertj.core.api.Assertions.assertThat;
public class GridTest {
private Grid grid;
......@@ -14,27 +14,25 @@ public class GridTest {
}
@Test
public void testGetNeighbours(){
assertThat(grid.getNeighbours(1,1), is(notNullValue()));
assertThat(grid.getNeighbours(1,1), hasSize(equalTo(8)));
assertThat(grid.getNeighbours(1,1),
containsInAnyOrder(grid.getCell(0,0),
public void testGetNeighbors(){
assertThat(grid.getNeighbors(1,1)).isNotNull();
assertThat(grid.getNeighbors(1,1)).hasSize(8);
assertThat(grid.getNeighbors(1,1))
.containsExactlyInAnyOrder(grid.getCell(0,0),
grid.getCell(0,1),
grid.getCell(0,2),
grid.getCell(1,0),
grid.getCell(1,2),
grid.getCell(2,0),
grid.getCell(2,1),
grid.getCell(2,2)));
grid.getCell(2,2));
}
@Test
public void testCountAliveNeighbours(){
assertThat(grid.countAliveNeighbours(1,1), is(equalTo(0)));
public void testCountAliveNeighbors(){
assertThat(grid.countAliveNeighbors(1,1)).isEqualTo(0);
grid.getCell(2,2).setState(CellState.ALIVE);
grid.getCell(0,0).setState(CellState.ALIVE);
assertThat(grid.countAliveNeighbours(1,1), is(equalTo(2)));
assertThat(grid.countAliveNeighbors(1,1)).isEqualTo(2);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment