Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • s20026898/tp-6
  • boukenze.b/jeu-de-la-vie-tp-3
  • b22015696/game-of-life-template
  • s23026062/sahin-game-of-life-template
  • m22023183/game-of-life-MALEK
  • z23012739/game-of-life-template
  • p23021107/poussardin-malo-game-of-life-template
  • o21225801/game-of-life-template
  • alaboure/game-fo-life-template
  • t22007439/game-of-life-toullec
  • b23021750/game-of-life
  • c22029830/game-of-life-template-rafi
  • b23025683/game-of-life-template-tp-6
  • gnaves/game-of-life-template
  • a22025223/game-of-life-template-cristel
  • f22024692/game-of-life-template-paolo-mathis-erwan
  • t21233923/game-fo-life-template
  • h21231335/game-fo-life-template
  • l22023519/game-of-life-template-salma
  • p23020787/game-of-life-template
  • b21232450/game-of-life-template
  • s22031458/game-of-life
  • n21223697/tp-4-ngom
  • a22027291/game-of-life-of-salim
  • k22029508/tp-4
  • s19033421/game-of-life-template
  • b21229750/jeu-de-la-vie-tp-3
  • saddem.r/game-of-life-template
  • l3_s3_infoamu/s3/programmation-2/game-fo-life-template
29 results
Select Git revision
Loading items
Show changes
package model;
import org.junit.jupiter.api.Test;
import java.util.List;
import static model.State.count;
import static org.junit.jupiter.api.Assertions.*;
class StateTest {
@Test
public void testCountMethodWithInteger() {
List<Integer> neighbours = List.of(1, 2, 1, 3, 1);
int result = count(1, neighbours);
assertEquals(3, result);
}
@Test
public void testCountMethodWithString() {
List<String> neighbours = List.of("apple", "banana", "apple", "cherry", "apple");
int result = count("apple", neighbours);
assertEquals(3, result);
}
@Test
public void testCountMethodWithEmptyList() {
List<Double> neighbours = List.of();
int result = count(5.0, neighbours);
assertEquals(0, result);
}
@Test
public void testCountMethodWithNoMatchingElements() {
List<Character> neighbours = List.of('a', 'b', 'c');
int result = count('x', neighbours);
assertEquals(0, result);
}
}
\ No newline at end of file
package model.automata;
import javafx.scene.paint.Color;
import model.State;
import org.junit.jupiter.api.Test;
import java.util.List;
import static model.automata.GameOfLifeState.*;
import static org.junit.jupiter.api.Assertions.*;
class GameOfLifeStateTest {
@Test
public void testGetColor() {
assertEquals(Color.WHITE, DEAD.getColor());
assertEquals(Color.RED, ALIVE.getColor());
}
@Test
public void testNext() {
assertEquals(ALIVE.next(), DEAD);
assertEquals(DEAD.next(), ALIVE);
}
@Test
public void testAliveUpdate() {
// Test with three alive neighbors, should be ALIVE
List<GameOfLifeState> aliveNeighbors =
List.of(ALIVE, DEAD, ALIVE, DEAD, ALIVE);
assertEquals(ALIVE, ALIVE.update(aliveNeighbors));
// Test with two alive neighbors, should be ALIVE
List<GameOfLifeState> twoAliveNeighbors =
List.of(ALIVE, DEAD, ALIVE, DEAD, DEAD);
assertEquals(ALIVE, ALIVE.update(twoAliveNeighbors));
// Test with four alive neighbors, should be DEAD
List<GameOfLifeState> fourAliveNeighbors =
List.of(ALIVE, ALIVE, DEAD, ALIVE, ALIVE);
assertEquals(DEAD, ALIVE.update(fourAliveNeighbors));
// Test with zero alive neighbors, should be DEAD
List<GameOfLifeState> zeroAliveNeighbors =
List.of(DEAD, DEAD, DEAD, DEAD);
assertEquals(DEAD, ALIVE.update(zeroAliveNeighbors));
}
@Test
public void testDeadUpdate() {
// Test with three alive neighbors, should be ALIVE
List<GameOfLifeState> aliveNeighbors =
List.of(ALIVE, DEAD, ALIVE, DEAD, ALIVE);
assertEquals(ALIVE, DEAD.update(aliveNeighbors));
// Test with two alive neighbors, should be DEAD
List<GameOfLifeState> twoAliveNeighbors =
List.of(ALIVE, DEAD, ALIVE, DEAD, DEAD);
assertEquals(DEAD, DEAD.update(twoAliveNeighbors));
// Test with four alive neighbors, should be DEAD
List<GameOfLifeState> fourAliveNeighbors =
List.of(ALIVE, ALIVE, DEAD, ALIVE, ALIVE);
assertEquals(DEAD, DEAD.update(fourAliveNeighbors));
// Test with zero alive neighbors, should be DEAD
List<GameOfLifeState> zeroAliveNeighbors =
List.of(DEAD, DEAD, DEAD, DEAD);
assertEquals(DEAD, DEAD.update(zeroAliveNeighbors));
}
}
\ No newline at end of file