diff --git a/src/main.rs b/src/main.rs index dd5a77a..fb7b826 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,4 +181,44 @@ mod tests { assert!(open_file("two_robots.txt").is_ok()); assert!(open_file("test_unexisting_file.extension").is_err()); } + + #[test] + fn test_create_map() { + let mut w: World = World { + x: 5, + y: 5, + map: Vec::new(), + }; + w.create_map(); + assert_eq!(w.map, vec!['.'; 25]); + } + + #[test] + fn test_set_robot() { + let r = Robot { + id: 0, + o: Orientation::N, + p: Position { x: 0, y: 0 }, + q: Queue::new(), + }; + let mut w: World = World { + x: 2, + y: 2, + map: Vec::new(), + }; + w.create_map(); + w.set_robot(r); + assert_eq!(w.map, vec!['↑', '.', '.', '.']); + } + + #[test] + fn test_empty_position() { + let mut w: World = World { + x: 2, + y: 2, + map: Vec::new(), + }; + w.create_map(); + assert!(w.empty_position(Position { x: 0, y: 0 })); + } }