homework: add get_name method to room
This commit is contained in:
@@ -13,6 +13,10 @@ impl Room {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn is_valid_idx(&self, idx: usize) -> bool {
|
||||
idx < self.devices.len()
|
||||
}
|
||||
@@ -48,6 +52,7 @@ mod tests {
|
||||
]);
|
||||
let mut room = Room::new("test_room", devices);
|
||||
assert_eq!(room.name, "test_room");
|
||||
assert_eq!(room.get_name(), "test_room");
|
||||
room.print_status();
|
||||
|
||||
assert_eq!(format!("{}", room.get_device(0).unwrap().display()), "DEV:PSoc[ OFF : 0.0 ]");
|
||||
|
||||
Reference in New Issue
Block a user