Merge branch 'remove-instruction' into 'master'
Remove instruction See merge request mhart/DancingDroids!31
This commit is contained in:
commit
c27c403827
28
src/main.rs
28
src/main.rs
@ -135,13 +135,6 @@ enum Orientation {
|
||||
W,
|
||||
}
|
||||
|
||||
/// Enum to store all possible instructions.
|
||||
enum Instruction {
|
||||
L,
|
||||
R,
|
||||
F,
|
||||
}
|
||||
|
||||
/// Parse char and return corresponding orientation.
|
||||
fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
|
||||
match c {
|
||||
@ -153,15 +146,6 @@ fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse char and return corresponding instruction.
|
||||
fn parse_instruction(c: char) -> Result<Instruction, &'static str> {
|
||||
match c {
|
||||
'L' => Ok(Instruction::L),
|
||||
'R' => Ok(Instruction::R),
|
||||
'F' => Ok(Instruction::F),
|
||||
_ => Err("Invalid character, does not match any instructions"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve the content of a file and return it as a string.
|
||||
fn open_file(filename: &str) -> io::Result<String> {
|
||||
@ -204,14 +188,6 @@ mod tests {
|
||||
assert!(parse_orientation('Z').is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_instruction() {
|
||||
assert!(parse_instruction('L').is_ok());
|
||||
assert!(parse_instruction('R').is_ok());
|
||||
assert!(parse_instruction('F').is_ok());
|
||||
assert!(parse_instruction('Z').is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_open_file() {
|
||||
assert!(open_file("two_robots.txt").is_ok());
|
||||
@ -289,10 +265,6 @@ mod tests {
|
||||
w.create();
|
||||
r.move_forward(&mut w);
|
||||
assert_eq!(0, r.p.y);
|
||||
r.move_right(&mut w);
|
||||
assert_eq!(2, r.p.x);
|
||||
r.move_left(&mut w);
|
||||
assert_eq!(1, r.p.x);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user