feat: update test of app
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -14,7 +16,7 @@ public class AppTest {
|
|||||||
// Simulate user input with proper line endings
|
// Simulate user input with proper line endings
|
||||||
// First 1 is to select the int type of Symboles and after, Symboles are entered
|
// First 1 is to select the int type of Symboles and after, Symboles are entered
|
||||||
// (1 to 16)
|
// (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()));
|
System.setIn(new ByteArrayInputStream(simulatedInput.getBytes()));
|
||||||
|
|
||||||
// Create a new Sudoku
|
// Create a new Sudoku
|
||||||
@@ -44,9 +46,22 @@ public class AppTest {
|
|||||||
// Cleanup
|
// Cleanup
|
||||||
System.setIn(System.in);
|
System.setIn(System.in);
|
||||||
|
|
||||||
int taille = expectedSymbols.size() - 1;
|
int taille = 16;
|
||||||
for (Symbole symbole : expectedSymbols) {
|
for (int i = 0; i < taille; i++) {
|
||||||
sudoku.getGrille().setCase(taille++, taille++, symbole);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user