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() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rover_run() {
|
fn rover_run() {
|
||||||
assert_eq!(1,1);
|
assert_eq!(1,1);
|
||||||
}
|
let r = (1 as i32, 1 as i32, rover::Facing::N);
|
||||||
|
assert_eq!(rover::forward(r),
|
||||||
#[test]
|
(1 as i32, 0 as i32, rover::Facing::N));
|
||||||
fn failure_run() {
|
|
||||||
assert_eq!(1,0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user