From cd775fb0b43119a9c46bd5e14ec03b5a15ab199d Mon Sep 17 00:00:00 2001 From: EliasCubz Date: Sat, 7 Nov 2020 20:20:47 +0100 Subject: [PATCH 1/3] added test parse_config --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4d64130..94921f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,7 +199,7 @@ fn main() -> Result<(), Box> { let matches = App::new("DancingDroids") .version("0.3.0") .about("When droids dance togethers") - .arg( + arg( Arg::with_name("file") .short("f") .long("file") @@ -319,4 +319,16 @@ mod tests { h.insert(robot::Position { x: 2, y: 3 }, 1); assert!(check_collisions(&r, &h).is_ok()); } + + fn test_parse() { + let conf: String = String::from("5 5\n\n1 1 N\nFLLFRF\n\n3 2 S\nFFLFRRF\n"); + let mut robot_pool: Vec = Vec::new(); + assert!(parse_config(conf, &mut robot_pool).is_ok()); + let conf: String = String::from("5 a\n\n1 1 N\nFLLFRF\n\n3 2 S\nFFLFRRF\n"); + assert!(parse_config(conf, &mut robot_pool).is_err()); + let conf: String = String::from("5 5\n\n1 1 N\nZLLFRF\n\n3 2 S\nFFLFRRF\n"); + assert!(parse_config(conf, &mut robot_pool).is_err()); + let conf: String = String::from("5 5\n\n1 1 R\nFLLFRF\n\n3 2 S\nFFLFRRF\n"); + assert!(parse_config(conf, &mut robot_pool).is_err()); + } } From 3d16f9934726e9d178975e79d9e69cd2315c2d3f Mon Sep 17 00:00:00 2001 From: EliasCubz Date: Sat, 7 Nov 2020 20:24:43 +0100 Subject: [PATCH 2/3] added test parse_config and corrected my mess --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 94921f7..5c9fb33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,7 +199,7 @@ fn main() -> Result<(), Box> { let matches = App::new("DancingDroids") .version("0.3.0") .about("When droids dance togethers") - arg( + .arg( Arg::with_name("file") .short("f") .long("file") From ce7f802a8cf4a2502c8e094073b8e64f5f3aab10 Mon Sep 17 00:00:00 2001 From: EliasCubz Date: Sat, 7 Nov 2020 20:45:02 +0100 Subject: [PATCH 3/3] cargo fmt ftw --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c9fb33..c1bba05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -319,8 +319,8 @@ mod tests { h.insert(robot::Position { x: 2, y: 3 }, 1); assert!(check_collisions(&r, &h).is_ok()); } - - fn test_parse() { + #[test] + fn test_parse() { let conf: String = String::from("5 5\n\n1 1 N\nFLLFRF\n\n3 2 S\nFFLFRRF\n"); let mut robot_pool: Vec = Vec::new(); assert!(parse_config(conf, &mut robot_pool).is_ok());