don't hardcode return value in forward()
This commit is contained in:
parent
71d9c799b6
commit
9348808ea9
12
src/main.rs
12
src/main.rs
@ -9,7 +9,10 @@ mod rover {
|
||||
type Rover = (i32, i32, Facing);
|
||||
|
||||
pub fn forward(r : Rover) -> Rover {
|
||||
(1 as i32, 0 as i32, Facing::N)
|
||||
match r {
|
||||
(lon, lat, direction) =>
|
||||
(lon as i32, lat - 1 as i32, direction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +21,13 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rover_run() {
|
||||
assert_eq!(1,1);
|
||||
fn move_north() {
|
||||
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));
|
||||
|
||||
let r = (1 as i32, 3 as i32, rover::Facing::N);
|
||||
assert_eq!(rover::forward(r),
|
||||
(1 as i32, 2 as i32, rover::Facing::N));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user