Test: First simple solving test
This commit is contained in:
41
src/sudoku_solver.rs
Normal file
41
src/sudoku_solver.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user