feat: update test of app

This commit is contained in:
2025-02-06 18:28:36 +01:00
parent 1ad9c0500e
commit 909219a8f8

View File

@@ -7,6 +7,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import org.junit.jupiter.api.Test;
public class AppTest {
@Test
@@ -14,7 +16,7 @@ public class AppTest {
// Simulate user input with proper line endings
// First 1 is to select the int type of Symboles and after, Symboles are entered
// (1 to 16)
String simulatedInput = "1\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n";
String simulatedInput = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n";
System.setIn(new ByteArrayInputStream(simulatedInput.getBytes()));
// Create a new Sudoku
@@ -44,9 +46,22 @@ public class AppTest {
// Cleanup
System.setIn(System.in);
int taille = expectedSymbols.size() - 1;
for (Symbole symbole : expectedSymbols) {
sudoku.getGrille().setCase(taille++, taille++, symbole);
int taille = 16;
for (int i = 0; i < taille; i++) {
sudoku.getGrille().setCase(i, i, expectedSymbols.get(i));
}
sudoku.getGrille().creerBlocCarre();
sudoku.ajouterContrainte(new ContrainteLigne());
sudoku.ajouterContrainte(new ContrainteColonne());
sudoku.ajouterContrainte(new ContrainteBloc());
System.out.println(sudoku.getGrille().toString());
Resolveur resolveur = new ResolveurBacktraceSimple(sudoku);
resolveur.resoudre(sudoku, false);
System.out.println("Sudoku résolu :");
System.out.println(sudoku.getGrille().toString());
}
}