tout ca tout ca

This commit is contained in:
Victor
2024-06-26 22:43:57 +02:00
parent de585edfb7
commit 7c755a5ce3
3 changed files with 39 additions and 10 deletions

View File

@@ -9,10 +9,12 @@ import org.junit.jupiter.api.Test;
class ChessboardTest {
private Chessboard chessboard;
private EightQueensSolver solver;
@BeforeEach
public void beforeEach() {
this.chessboard = new Chessboard();
this.solver = new EightQueensSolver();
}
@Test
@@ -74,14 +76,40 @@ class ChessboardTest {
return x >= 0 && x < Chessboard.SIZE && y >= 0 && y < Chessboard.SIZE;
}
void testWinningSolution(Chessboard chessboard) {
assertEquals(Chessboard.SIZE, chessboard.getNumberOfQueen(),"Devrait etre egal a "+Chessboard.SIZE);
for(int i = 0; i< Chessboard.SIZE ;i++){
for(int j = 0; j< Chessboard.SIZE ;j++){
if(chessboard.gameBoard[i][j] != 0){
chessboard.removeQueen(i,j);
assertTrue(chessboard.VerifAccessible(i,j));
chessboard.placeQueen(i,j);
}
}
}
}
@Test
void testWinningSolution() {
// Placer les reines aux positions données
void TestSolverSim() {
solver.SolverSim(0);
testWinningSolution(solver.chessboard);
}
@Test
void TestSolverVic() {
solver.SolverVic(0);
testWinningSolution(solver.chessboard);
}
@Test
void TestKnownedWinningSolution(){
int[][] positions = {
{0, 0}, {1, 4}, {2, 7}, {3, 5},
{4, 2}, {5, 6}, {6, 1}, {7, 3}
};
for (int[] pos : positions) {
assertTrue(this.chessboard.VerifAccessible(pos[0], pos[1]),
"La position (" + pos[0] + "," + pos[1] + ") devrait être accessible.");
@@ -89,7 +117,8 @@ class ChessboardTest {
assertFalse(this.chessboard.VerifAccessible(pos[0], pos[1]),
"La position (" + pos[0] + "," + pos[1] + ") ne devrait plus être accessible.");
}
testWinningSolution(this.chessboard);
}
}