2019-05-23 12:26:28 +02:00
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
2019-05-27 17:36:46 +02:00
|
|
|
import org.junit.jupiter.api.AfterEach;
|
2019-05-23 12:26:28 +02:00
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
2019-05-23 13:25:30 +02:00
|
|
|
import joueurs.Joueur;
|
2019-05-23 12:26:28 +02:00
|
|
|
import piecesEchiquier.*;
|
|
|
|
|
2019-05-27 18:15:14 +02:00
|
|
|
/*
|
|
|
|
* @AfterEach is used to signal that the annotated method should beexecuted after each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
|
|
|
|
* org.junit.jupiter.api.AfterEach;
|
|
|
|
*
|
|
|
|
* @BeforeEach is used to signal that the annotated method should beexecuted before each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
|
|
|
|
* org.junit.jupiter.api.BeforeEach;
|
|
|
|
*
|
|
|
|
* @Test is used to signal that the annotated method is a test method.
|
|
|
|
* @Test methods must not be private or staticand must not return a value.
|
|
|
|
* @Test methods may optionally declare parameters to beresolved by ParameterResolvers.
|
|
|
|
* @Test may also be used as a meta-annotation in order to createa custom composed annotation that inherits the semantics of @Test.
|
|
|
|
* org.junit.jupiter.api.Test;
|
|
|
|
* */
|
|
|
|
|
2019-05-23 12:26:28 +02:00
|
|
|
class testGeneraux {
|
|
|
|
private Echiquier e;
|
2019-05-23 13:25:30 +02:00
|
|
|
private Joueur jb;
|
2019-05-27 17:36:46 +02:00
|
|
|
private Joueur jn;
|
2019-05-23 12:26:28 +02:00
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
public void initialisation() {
|
|
|
|
e = new Echiquier();
|
2019-05-23 13:25:30 +02:00
|
|
|
jb = new Joueur("Joueur Blanc","Blanc");
|
2019-05-27 17:36:46 +02:00
|
|
|
jn = new Joueur("Joueur Noir", "Noir");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AfterEach
|
|
|
|
public void netoyage () {
|
|
|
|
e = null;
|
|
|
|
jb = null;
|
|
|
|
jn = null;
|
2019-05-23 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testEchiquier() {
|
|
|
|
//toString
|
|
|
|
assertEquals("8 TN CN FN QN KN FN CN TN \n"
|
|
|
|
+ "7 PN PN PN PN PN PN PN PN \n"
|
|
|
|
+ "6 .. .. .. .. .. .. .. .. \n"
|
|
|
|
+ "5 .. .. .. .. .. .. .. .. \n"
|
|
|
|
+ "4 .. .. .. .. .. .. .. .. \n"
|
|
|
|
+ "3 .. .. .. .. .. .. .. .. \n"
|
|
|
|
+ "2 PB PB PB PB PB PB PB PB \n"
|
|
|
|
+ "1 TB CB FB QB KB FB CB TB \n"
|
|
|
|
+ " A B C D E F G H", e.toString());
|
|
|
|
|
|
|
|
//verificationMouvement fait dans test piece
|
|
|
|
|
|
|
|
//estVide
|
2019-05-23 13:25:30 +02:00
|
|
|
for (int x = 1; x < 9; x++) {
|
|
|
|
for (int y = 3; y < 7; y++) {
|
|
|
|
Position p = new Position(x, y);
|
2019-05-23 12:26:28 +02:00
|
|
|
assertTrue(e.estVide(p));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 13:25:30 +02:00
|
|
|
for (int x = 1; x < 9; x++) {
|
|
|
|
for (int y = 1; y < 3; y++) {
|
|
|
|
Position p = new Position(x, y);
|
2019-05-23 12:26:28 +02:00
|
|
|
assertFalse(e.estVide(p));
|
|
|
|
}
|
|
|
|
}
|
2019-05-23 13:25:30 +02:00
|
|
|
for (int x = 1; x < 9; x++) {
|
|
|
|
for (int y = 7; y < 9; y++) {
|
|
|
|
Position p = new Position(x, y);
|
2019-05-23 12:26:28 +02:00
|
|
|
assertFalse(e.estVide(p));
|
|
|
|
}
|
|
|
|
}
|
2019-05-27 17:36:46 +02:00
|
|
|
|
|
|
|
e.verificationMouvement(jb, "e2", "e4");
|
|
|
|
Position p1 = new Position (5, 4);
|
|
|
|
assertFalse(e.estVide(p1));
|
|
|
|
Position p2 = new Position (5, 2);
|
|
|
|
assertTrue(e.estVide(p2));
|
2019-05-23 12:26:28 +02:00
|
|
|
}
|
2019-05-23 13:25:30 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testePiece () {
|
|
|
|
//aBouge
|
|
|
|
e.verificationMouvement(jb, "C2", "c3");
|
|
|
|
assertTrue(e.getPionB3().aBouge());
|
|
|
|
|
|
|
|
assertFalse(e.getCavalierB1().aBouge());
|
|
|
|
}
|
2019-05-27 17:36:46 +02:00
|
|
|
|
|
|
|
/*@Test
|
|
|
|
public void testEchec () {
|
|
|
|
e.verificationMouvement(jb, "e2", "e4");
|
|
|
|
e.verificationMouvement(jn, "e7", "e5");
|
|
|
|
e.verificationMouvement(jb, "d1", "g4");
|
|
|
|
e.verificationMouvement(jn, "f7", "f5");
|
|
|
|
e.verificationMouvement(jb, "g4", "g6");
|
|
|
|
assertTrue(e.getRoiN1().metEnEchec(e, e.getReineB1()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEchecEtMat () {
|
|
|
|
System.out.println("prout");
|
|
|
|
e.verificationMouvement(jb, "e2", "e4");
|
|
|
|
e.verificationMouvement(jn, "e7", "e5");
|
|
|
|
e.verificationMouvement(jb, "g1", "h3");
|
|
|
|
e.verificationMouvement(jn, "b8", "c6");
|
|
|
|
e.verificationMouvement(jb, "e1", "c4");
|
|
|
|
e.verificationMouvement(jn, "d7", "d6");
|
|
|
|
e.verificationMouvement(jb, "b1", "c3");
|
|
|
|
e.verificationMouvement(jn, "c8", "g4");
|
|
|
|
e.verificationMouvement(jb, "e3", "d5");
|
|
|
|
e.verificationMouvement(jn, "g4", "d1");
|
|
|
|
e.verificationMouvement(jb, "c4", "e7");
|
|
|
|
e.verificationMouvement(jn, "e8", "e7");
|
|
|
|
e.verificationMouvement(jb, "c3", "d5");
|
|
|
|
assertTrue(e.getRoiN1().enEchecEtMat(e, e.getCavalierB1()));
|
|
|
|
}*/
|
2019-05-23 12:26:28 +02:00
|
|
|
}
|