Écrire des tests pour pas bloquer!
https://doc.rust-lang.org/book/ch11-01-writing-tests.html
Par exemple: ;)
[cfg(tests)]
mod tests {
#[test]
/// Test de la fonction next avec un robot qui avance vers le nord.
fn test_move() {
let robot = (5, 5, Orientation::North);
let expected (5, 6, Orientation::North);
assert_eq!(next(robot.0, robot.1, robot.2, Instruction::Forward), expected);
}
#[test]
fn test_collisions() {
use Orientation as O;
use Instruction as I;
let x_max = 10;
let y_max = 10;
let world = [
(5, 5, O::North, vec![I::Left]),
(5, 7, O::South, vec![I::Forward]),
];
let expected = [
(5, 6, O::West, vec![]),
(5, 7, O::South, vec![]),
];
assert_eq!(&run(x_max, y_max, world), &expected);
}
Edited by Viala axel