diff --git a/src/world.rs b/src/world.rs index 357b82d..43afa6e 100644 --- a/src/world.rs +++ b/src/world.rs @@ -3,3 +3,31 @@ pub struct World { pub x: i32, pub y: i32, } + +pub fn is_instruction(v: &Vec) -> bool { + for c in v { + match c { + 'F' => continue, + 'R' => continue, + 'L' => continue, + _ => return false, + } + } + true +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn is_instruction_test() { + let v = vec!['F', 'R', 'L', 'F']; + assert!(is_instruction(&v)); + } + #[test] + #[should_panic] + fn is_instruction_test_fail() { + let v = vec!['F', 'R', 'L', 'Z']; + assert!(is_instruction(&v)); + } +}