From bc0de9955c375cf27d52c9934403964205afc182 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:16:15 +0100 Subject: formatting --- tests/client_ui.rs | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'tests/client_ui.rs') diff --git a/tests/client_ui.rs b/tests/client_ui.rs index 7a1b675..44febde 100644 --- a/tests/client_ui.rs +++ b/tests/client_ui.rs @@ -1,9 +1,9 @@ +use std::time::Duration; use zagan_bet::client::ui::{ - command_names, completion_lines, display_width, first_contact_lines, format_pong, - help_lines, host_lines, input_cursor_column, lines_to_move_up, parse_bet_arg, record_history, + command_names, completion_lines, display_width, first_contact_lines, format_pong, help_lines, + host_lines, input_cursor_column, lines_to_move_up, parse_bet_arg, record_history, visual_line_count, }; -use std::time::Duration; #[test] fn help_has_no_source_indentation() { @@ -27,13 +27,7 @@ fn help_documents_every_command() { fn completion_knows_every_command() { let commands = command_names(); for expected in [ - "connect", - "games", - "play", - "hosts", - "send", - "logout", - "quit", + "connect", "games", "play", "hosts", "send", "logout", "quit", ] { assert!( commands.contains(&expected), @@ -109,19 +103,12 @@ fn display_width_ignores_ansi_sequences() { fn visual_line_count_ignores_ansi_sequences() { let styled = format!("\x1b[31m{}\x1b[0m", "x".repeat(75)); assert_eq!(visual_line_count(&[styled], 72), 2); - assert_eq!( - visual_line_count(&["\x1b[31m18\x1b[0m".to_string()], 80), - 1 - ); + assert_eq!(visual_line_count(&["\x1b[31m18\x1b[0m".to_string()], 80), 1); } #[test] fn visual_line_count_accounts_for_terminal_wrapping() { - let lines = vec![ - "12345".to_string(), - "123456".to_string(), - String::new(), - ]; + let lines = vec!["12345".to_string(), "123456".to_string(), String::new()]; assert_eq!(visual_line_count(&lines, 5), 4); // 1 + 2 + 1 assert_eq!(visual_line_count(&lines, 6), 3); // 1 + 1 + 1 @@ -146,7 +133,10 @@ fn completions_wrap_within_the_requested_width() { let commands = command_names(); let lines = completion_lines(&commands, 40); - assert_eq!(lines.first().map(String::as_str), Some("Possible completions:")); + assert_eq!( + lines.first().map(String::as_str), + Some("Possible completions:") + ); for line in &lines[1..] { assert!( line.len() <= 40, @@ -208,10 +198,7 @@ fn pong_is_formatted_to_one_decimal() { fn host_lines_fit_an_80_column_terminal() { let fingerprint = "a4d6f80784154c2cb739a1df61ab3e9038ed731ee2e05c7611457ac741b3834c"; let lines = host_lines(&[ - ( - "127.0.0.1:11525".to_string(), - Some(fingerprint.to_string()), - ), + ("127.0.0.1:11525".to_string(), Some(fingerprint.to_string())), ("unknown.example:443".to_string(), None), ]); @@ -233,10 +220,7 @@ fn hosts_sharing_a_fingerprint_are_shown_as_one_server() { let lines = host_lines(&[ ("10.0.0.100:11525".to_string(), Some(key.to_string())), ("127.0.0.1:11525".to_string(), Some(key.to_string())), - ( - "other.example:11525".to_string(), - Some("ff".repeat(32)), - ), + ("other.example:11525".to_string(), Some("ff".repeat(32))), ]); assert_eq!( @@ -264,7 +248,10 @@ fn hosts_without_a_fingerprint_are_never_merged() { assert!(lines.contains(&" a.example:443".to_string())); assert!(lines.contains(&" b.example:443".to_string())); assert_eq!( - lines.iter().filter(|line| line.contains("no fingerprint")).count(), + lines + .iter() + .filter(|line| line.contains("no fingerprint")) + .count(), 2 ); } -- cgit v1.2.3