#![allow(dead_code)]
#[derive(Clone, Copy)]
pub enum Action {
MoveDown,
MoveUp,
PageDown,
PageUp,
SelectFirst,
SelectLast,
PreviousPane,
NextPane,
ToggleSystemView,
ToggleDrives,
RefreshNow,
Resize {
width: u16,
height: u16,
},
Quit,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn action_variants_exist() {
let actions = [
Action::MoveDown,
Action::MoveUp,
Action::PageDown,
Action::PageUp,
Action::SelectFirst,
Action::SelectLast,
Action::PreviousPane,
Action::NextPane,
Action::ToggleSystemView,
Action::ToggleDrives,
Action::RefreshNow,
Action::Resize {
width: 80,
height: 24,
},
Action::Quit,
];
assert!(matches!(actions[0], Action::MoveDown));
assert!(matches!(actions[1], Action::MoveUp));
assert!(matches!(actions[2], Action::PageDown));
assert!(matches!(actions[3], Action::PageUp));
assert!(matches!(actions[4], Action::SelectFirst));
assert!(matches!(actions[5], Action::SelectLast));
assert!(matches!(actions[6], Action::PreviousPane));
assert!(matches!(actions[7], Action::NextPane));
assert!(matches!(actions[8], Action::ToggleSystemView));
assert!(matches!(actions[9], Action::ToggleDrives));
assert!(matches!(actions[10], Action::RefreshNow));
assert!(matches!(
actions[11],
Action::Resize {
width: 80,
height: 24
}
));
assert!(matches!(actions[12], Action::Quit));
}
#[test]
fn resize_carries_dimensions() {
let action = Action::Resize {
width: 120,
height: 40,
};
match action {
Action::Resize { width, height } => {
assert_eq!(width, 120);
assert_eq!(height, 40);
}
_ => panic!("expected Resize"),
}
}
}