diff options
Diffstat (limited to 'tests/client_ui.rs')
| -rw-r--r-- | tests/client_ui.rs | 19 |
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 @@ | |||
| 1 | use zagan_bet::client::ui::{ | 1 | use 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 | }; |
| 5 | use std::time::Duration; | 6 | use 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] |
| 102 | fn 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] | ||
| 101 | fn input_cursor_is_after_the_removed_character() { | 120 | fn 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); |
