rover moves forward northward when pointing north

This commit is contained in:
Daniel Barlow 2023-10-31 22:51:32 +00:00
parent a4a80f450a
commit 71d9c799b6

View File

@ -1,15 +1,27 @@
fn main() {
println!("Hello, world!");
}
mod rover {
#[derive(Debug,PartialEq)]
pub enum Facing { N, E, S, W }
type Rover = (i32, i32, Facing);
pub fn forward(r : Rover) -> Rover {
(1 as i32, 0 as i32, Facing::N)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn rover_run() {
assert_eq!(1,1);
}
#[test]
fn failure_run() {
assert_eq!(1,0);
let r = (1 as i32, 1 as i32, rover::Facing::N);
assert_eq!(rover::forward(r),
(1 as i32, 0 as i32, rover::Facing::N));
}
}