aboutsummaryrefslogtreecommitdiff
path: root/src/main/rust
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/rust')
-rw-r--r--src/main/rust/main.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/rust/main.rs b/src/main/rust/main.rs
index 9248661..97e194c 100644
--- a/src/main/rust/main.rs
+++ b/src/main/rust/main.rs
@@ -164,6 +164,36 @@ mod tests {
}
#[test]
+ fn handle_key_event_inc_n() {
+ let mut app = App::default();
+ let n = 8;
+
+ for i in 1..=n {
+ let res = app.handle_key_event(KeyCode::Right.into());
+ assert!(res.is_ok());
+ assert_eq!(app.counter, i);
+ }
+ assert_eq!(app.counter, n);
+ }
+
+ #[test]
+ fn handle_key_event_inc_n_dec() {
+ let mut app = App::default();
+ let n = 8;
+
+ for i in 1..=n {
+ let res = app.handle_key_event(KeyCode::Right.into());
+ assert!(res.is_ok());
+ assert_eq!(app.counter, i);
+ }
+ assert_eq!(app.counter, n);
+
+ let res = app.handle_key_event(KeyCode::Left.into());
+ assert!(res.is_ok());
+ assert_eq!(app.counter, n - 1);
+ }
+
+ #[test]
fn handle_key_event_exit() {
let mut app = App::default();
let res = app.handle_key_event(KeyCode::Char('q').into());