Test: First simple solving test

This commit is contained in:
Jonas Zeunert
2024-02-18 20:36:12 +01:00
parent f414a71c84
commit 0ef4449e43
4 changed files with 61 additions and 7 deletions

41
src/sudoku_solver.rs Normal file
View File

@@ -0,0 +1,41 @@
use crate::playfield::Playfield;
pub struct SudokuSolver {
playfield: Playfield,
}
impl SudokuSolver {
pub fn new(playfield: &Playfield) -> SudokuSolver {
Self {
playfield: playfield.clone(),
}
}
pub fn solve(&self) -> Playfield {
return self.playfield.clone();
}
fn populate_possible_values(&self) {
for row in &self.playfield.fields {
for field in row {
if field.value.is_some() {
continue;
}
}
}
}
}
#[cfg(test)]
mod tests {
mod solve {
use super::super::*;
#[test]
fn simple() {
let playfield = Playfield::new(&"1 2 3 2 3 1 3 1 0".to_string(), 3);
let expected = Playfield::new(&"1 2 3 2 3 1 3 1 2".to_string(), 3);
let solved = SudokuSolver::new(&playfield).solve();
assert_eq!(solved, expected);
}
}
}