Merge branch 'test-world' into 'master'
test of World methods See merge request mhart/DancingDroids!24
This commit is contained in:
commit
73674d26de
40
src/main.rs
40
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 }));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user