commit862ff6e08dAuthor: Morph01 <thibaut6969delastreet@gmail.com> Date: Mon Jan 20 12:49:38 2025 +0100 feat: affichage de la grille colorée et vérification de tt les contraintes commitb1dde68ec1Author: Morph01 <thibaut6969delastreet@gmail.com> Date: Sun Jan 5 11:16:34 2025 +0100 feat: add constraint management and validation to Sudoku class commitd8486a3bd7Author: Morph01 <thibaut6969delastreet@gmail.com> Date: Sun Jan 5 11:13:19 2025 +0100 feat: implement constraint classes for Sudoku (row, column, block) commit8945072074Author: Morph01 <thibaut6969delastreet@gmail.com> Date: Sun Jan 5 11:12:59 2025 +0100 refactor: rename methods to French for consistency in the Sudoku application commite35123e9feAuthor: Morph01 <thibaut6969delastreet@gmail.com> Date: Sun Jan 5 11:11:40 2025 +0100 fix: update build.gradle to use testRuntimeOnly for JUnit Jupiter engine
57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package sudoku;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
|
|
public class TestBloc {
|
|
@Test
|
|
public void testBloc() {
|
|
System.out.println("TEST BLOC : ");
|
|
System.out.println(new App().getGreeting());
|
|
// Create a new Sudoku
|
|
Sudoku sudoku = new Sudoku(9);
|
|
sudoku.getGrille().setSymbolesPossibles(new ArrayList<>(Arrays.asList(
|
|
Symbole.of(1),
|
|
Symbole.of(2),
|
|
Symbole.of(3),
|
|
Symbole.of(4),
|
|
Symbole.of(5),
|
|
Symbole.of(6),
|
|
Symbole.of(7),
|
|
Symbole.of(8),
|
|
Symbole.of(9))));
|
|
|
|
// Add constraints
|
|
sudoku.ajouterContrainte(new ContrainteBloc());
|
|
|
|
sudoku.getGrille().setCase(0, 0, Symbole.of(1));
|
|
sudoku.getGrille().setCase(6, 1, Symbole.of(2));
|
|
sudoku.getGrille().setCase(2, 2, Symbole.of(3));
|
|
sudoku.getGrille().setCase(0, 3, Symbole.of(4));
|
|
sudoku.getGrille().setCase(4, 4, Symbole.of(5));
|
|
sudoku.getGrille().setCase(0, 5, Symbole.of(6));
|
|
sudoku.getGrille().setCase(5, 6, Symbole.of(7));
|
|
sudoku.getGrille().setCase(0, 7, Symbole.of(8));
|
|
sudoku.getGrille().setCase(4, 8, Symbole.of(9));
|
|
//doublon bloc
|
|
sudoku.getGrille().setCase(1, 1, Symbole.of(1));
|
|
assertFalse(sudoku.estValide(sudoku.getGrille().getCase(1, 1)));
|
|
|
|
sudoku.getGrille().creerBlocCarre();
|
|
|
|
System.out.println("Sudoku :");
|
|
System.out.println(sudoku.getGrille().toString());
|
|
|
|
System.out.println("Blocs :");
|
|
sudoku.getGrille().printBlocs();
|
|
|
|
System.out.println("Symboles possibles :");
|
|
sudoku.getGrille().printSymbolesPossibles();
|
|
System.out.println("FIN TEST BLOC");
|
|
}
|
|
}
|