added test parse_config
This commit is contained in:
parent
0a00cb8931
commit
cd775fb0b4
14
src/main.rs
14
src/main.rs
@ -199,7 +199,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<robot::Robot> = 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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user