Gwendal in main : add test on futur constraints and enhance input symbol method (#1)

Co-authored-by: ROGER <gwendal.roger@etu.univ-lyon1.fr>
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2025-01-04 15:56:23 +00:00
parent 0c03f07345
commit 22e88a899f
9 changed files with 366 additions and 147 deletions

View File

@@ -1,17 +1,35 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package sudoku;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AppTest {
@Test
public void testExample() {
System.out.println("DOING TEST");
assertEquals(2 + 2, 4);
System.out.println("DONE TEST");
// Simulate user input
String simulatedInput = "1\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
System.setIn(new ByteArrayInputStream(simulatedInput.getBytes()));
// Create a new Sudoku
Sudoku sudoku = new Sudoku(9);
sudoku.getGrille().askSetSymbolesPossibles();
// Verify the symbols
ArrayList<Symbole> expectedSymbols = 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)));
assertEquals(expectedSymbols, sudoku.getGrille().getSymbolesPossibles());
}
}