From 31bc601dfd3366dbb717bbbb9f5bd7f7b11fe78b Mon Sep 17 00:00:00 2001 From: Jonas Zeunert Date: Fri, 16 Feb 2024 18:50:37 +0100 Subject: [PATCH] Test: Playfield test --- src/main.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1064060..6f56b46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,13 @@ use clap::{Parser, Subcommand}; #[derive(Parser)] #[command(version, about, long_about = None)] struct Cli { - // The sudoku field given as a 1x81 string from left to right, top to bottom, 0 denotes value + // The sudoku field given as a space separated string from left to right, top to bottom, 0 denotes value // absense field: String, + + // Size of one size of the field. For standard 3x3 input 3 (default) + #[arg(short, long)] + field_size: u16, } struct Playfield { @@ -21,14 +25,22 @@ struct Field { fn main() { let cli = Cli::parse(); - let playfield = parse_field(&cli.field); + let playfield = parse_playfield(&cli.field, cli.field_size); println!("Hello, world!"); } -fn parse_field(field: &String) -> Playfield {} +fn parse_playfield(field: &String, field_size: u16) -> Playfield {} +#[cfg(test)] mod tests { + use super::*; + #[test] - fn test_parse_field() {} + fn test_parse_field() { + let input = "1 2 3 0 0 0 1 2 3"; + let field_size = 2; + + let playfield = parse_playfield(&input.to_string(), field_size); + } }