summaryrefslogtreecommitdiffstats
path: root/tests/client_ui.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 23:31:54 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 23:31:54 +0100
commit7d18a268547734daf19a740b6533e9c1697baf1a (patch)
tree789f519a19b053b8ad0ff41d2828fe22c06fb21a /tests/client_ui.rs
parentv1.2.0: show the symbol paytable on the slots board (diff)
downloadzagan-bet-7d18a268547734daf19a740b6533e9c1697baf1a.tar.gz
zagan-bet-7d18a268547734daf19a740b6533e9c1697baf1a.zip
v1.2.1: track wrapped board lines and split the paytable
Diffstat (limited to 'tests/client_ui.rs')
-rw-r--r--tests/client_ui.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/client_ui.rs b/tests/client_ui.rs
index a22fbe7..ea432e0 100644
--- a/tests/client_ui.rs
+++ b/tests/client_ui.rs
@@ -1,6 +1,7 @@
1use zagan_bet::client::ui::{ 1use zagan_bet::client::ui::{
2 command_names, completion_lines, display_width, first_contact_lines, format_pong, 2 command_names, completion_lines, display_width, first_contact_lines, format_pong,
3 help_lines, host_lines, input_cursor_column, lines_to_move_up, parse_bet_arg, record_history, 3 help_lines, host_lines, input_cursor_column, lines_to_move_up, parse_bet_arg, record_history,
4 visual_line_count,
4}; 5};
5use std::time::Duration; 6use std::time::Duration;
6 7
@@ -98,6 +99,24 @@ fn redraw_moves_up_by_line_count_minus_one() {
98} 99}
99 100
100#[test] 101#[test]
102fn visual_line_count_accounts_for_terminal_wrapping() {
103 let lines = vec![
104 "12345".to_string(),
105 "123456".to_string(),
106 String::new(),
107 ];
108
109 assert_eq!(visual_line_count(&lines, 5), 4); // 1 + 2 + 1
110 assert_eq!(visual_line_count(&lines, 6), 3); // 1 + 1 + 1
111 assert_eq!(visual_line_count(&lines, 80), 3);
112 assert_eq!(visual_line_count(&[], 80), 0);
113
114 let wide = "x".repeat(75);
115 assert_eq!(visual_line_count(&[wide.clone()], 75), 1);
116 assert_eq!(visual_line_count(&[wide], 72), 2);
117}
118
119#[test]
101fn input_cursor_is_after_the_removed_character() { 120fn input_cursor_is_after_the_removed_character() {
102 assert_eq!(input_cursor_column(10, 8), 18); 121 assert_eq!(input_cursor_column(10, 8), 18);
103 assert_eq!(input_cursor_column(10, 0), 10); 122 assert_eq!(input_cursor_column(10, 0), 10);