From 402e1db27c9a0bda2234e139dbf9a16ff69b35d0 Mon Sep 17 00:00:00 2001 From: Kevin Hoerr Date: Wed, 25 Feb 2026 19:52:24 +0000 Subject: main.rs: Add more unit tests for inc/dec --- src/main/rust/main.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') 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 @@ -163,6 +163,36 @@ mod tests { assert_eq!(app.counter, 0); } + #[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(); -- cgit v1.3