rover moves forward northward when pointing north
This commit is contained in:
parent
a4a80f450a
commit
71d9c799b6
22
src/main.rs
22
src/main.rs
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user