projet-court-programmation-.../allumettes/TestRapide.java
2023-06-20 21:05:21 +02:00

55 lines
1.3 KiB
Java

package allumettes;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.util.Random;
import org.junit.*;
public class TestRapide {
Strategie strat = new Rapide();
@Test
public void TestSuperieur() throws CoupInvalideException {
Random rd = new Random();
for (int i = 0; i < 100; i++) {
Partie game = new Partie(rd.nextInt(1000) + Jeu.PRISE_MAX);
int nb = strat.nbPrise(game, "nom");
assertEquals(nb, Jeu.PRISE_MAX);
}
}
@Test
public void TestInferieur() throws CoupInvalideException {
for (int i = 1; i < Jeu.PRISE_MAX; i++) {
Partie game = new Partie(i);
int nb = strat.nbPrise(game, "nom");
assertNotEquals(nb, Jeu.PRISE_MAX);
assertEquals(nb, i);
}
}
@Test
public void TestArbitre() throws CoupInvalideException {
Joueur j1 = new Joueur("j1", new Rapide());
Joueur j2 = new Joueur("j2", new Rapide());
Arbitre arbitre = new Arbitre(j1, j2);
for (int i = 1; i < 100; i++) {
Partie game = new Partie(i);
while (game.getNombreAllumettes() > 0) {
arbitre.arbitrer(game);
}
}
}
}