commit 9a9bad4f7133f5f82e85068088dd34d19e3e36d0
parent 3af88ea712929c0cab6a352b432581c2e53ca8f8
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 3 Nov 2023 18:50:44 +0000
reduce test prolixity with smarter use statement
Diffstat:
| M | src/main.rs | | | 42 | +++++++++++++++++++++--------------------- |
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -86,67 +86,67 @@ mod driver {
#[cfg(test)]
mod tests {
- use super::{rover, driver};
- use super::rover::{Rover};
+ use super::driver;
+ use super::rover::{Rover, Facing,Rotation};
#[test]
fn move_north() {
- let r = Rover(1, 1, rover::Facing::N);
+ let r = Rover(1, 1, Facing::N);
assert_eq!(r.forward(),
- Rover(1, 0, rover::Facing::N));
+ Rover(1, 0, Facing::N));
- let r = Rover(1, 3, rover::Facing::N);
+ let r = Rover(1, 3, Facing::N);
assert_eq!(r.forward(),
- Rover(1, 2, rover::Facing::N));
+ Rover(1, 2, Facing::N));
}
#[test]
fn move_south() {
- let r = Rover(1, 1, rover::Facing::S);
+ let r = Rover(1, 1, Facing::S);
assert_eq!(r.forward(),
- Rover(1, 2, rover::Facing::S));
+ Rover(1, 2, Facing::S));
}
#[test]
fn move_west() {
- let r = Rover(1, 1, rover::Facing::W);
+ let r = Rover(1, 1, Facing::W);
assert_eq!(r.forward(),
- Rover(0, 1, rover::Facing::W));
+ Rover(0, 1, Facing::W));
}
#[test]
fn move_east() {
- let r = Rover(1, 1, rover::Facing::E);
+ let r = Rover(1, 1, Facing::E);
assert_eq!(r.forward(),
- Rover(2, 1, rover::Facing::E));
+ Rover(2, 1, Facing::E));
}
#[test]
fn move_backward() {
- let r = Rover(1, 1, rover::Facing::E);
+ let r = Rover(1, 1, Facing::E);
let r2 = r.forward();
assert_eq!(r2.backward(), r);
}
#[test]
fn spin_left() {
- let r = Rover(1, 1, rover::Facing::E);
- match r.rotate(rover::Rotation::Left) {
- Rover(_, _, facing) => assert_eq!(facing, rover::Facing::N)
+ let r = Rover(1, 1, Facing::E);
+ match r.rotate(Rotation::Left) {
+ Rover(_, _, facing) => assert_eq!(facing, Facing::N)
}
}
#[test]
fn spin_right() {
- let r = Rover(1, 1, rover::Facing::S);
- match r.rotate(rover::Rotation::Right) {
- Rover(_, _, facing) => assert_eq!(facing, rover::Facing::W)
+ let r = Rover(1, 1, Facing::S);
+ match r.rotate(Rotation::Right) {
+ Rover(_, _, facing) => assert_eq!(facing, Facing::W)
}
}
#[test]
fn drive() {
- let r = Rover(1, 1, rover::Facing::S);
+ let r = Rover(1, 1, Facing::S);
assert_eq!(driver::execute(&r, "ffrf"),
- Rover(0, 3, rover::Facing::W));
+ Rover(0, 3, Facing::W));
}
}