From bc0de9955c375cf27d52c9934403964205afc182 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:16:15 +0100 Subject: formatting --- tests/client_core.rs | 63 +++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) (limited to 'tests/client_core.rs') diff --git a/tests/client_core.rs b/tests/client_core.rs index e8b5646..176791e 100644 --- a/tests/client_core.rs +++ b/tests/client_core.rs @@ -4,6 +4,7 @@ //! logical `Effect`s that `ClientCore` emits, so assertions are about what a //! player would see, not about ANSI sequences. +use std::time::Duration; use zagan_bet::blackjack::BlackjackState; use zagan_bet::client::core::{ClientCore, Effect, InteractiveCommand, Key}; use zagan_bet::client::games::response::{ @@ -11,7 +12,6 @@ use zagan_bet::client::games::response::{ }; use zagan_bet::client::ui::command_names; use zagan_bet::crash::CrashState; -use std::time::Duration; const WIN3: &str = "CCCCLLCLODGSDGS"; const LOSS: &str = "CLOOGDSLCDCOGLS"; @@ -67,10 +67,7 @@ impl Screen { } Effect::SendLine(line) => sent.push(line.clone()), Effect::Interactive(command) => interactive.push(command.clone()), - Effect::Quit - | Effect::Disconnect - | Effect::ListHosts - | Effect::ForgetHost(_) => {} + Effect::Quit | Effect::Disconnect | Effect::ListHosts | Effect::ForgetHost(_) => {} } } } @@ -276,7 +273,8 @@ fn a_mega_win_shows_all_winning_lines() { assert_eq!(h.board().len(), 10); assert!(h.board()[7].contains("MEGA WIN! 700 PLN")); - assert!(h.board()[8].contains("Winning lines: 1 (top), 2 (middle), 3 (bottom), 4 (V), 5 (inverted V)")); + assert!(h.board()[8] + .contains("Winning lines: 1 (top), 2 (middle), 3 (bottom), 4 (V), 5 (inverted V)")); assert_eq!(h.board()[2].matches("{ C }").count(), 5); } @@ -423,10 +421,7 @@ fn help_lists_every_command() { let transcript = h.screen.lines.join("\n"); for command in command_names() { - assert!( - transcript.contains(command), - "help is missing '{command}'" - ); + assert!(transcript.contains(command), "help is missing '{command}'"); } } @@ -548,11 +543,7 @@ fn send_prints_the_echo() { h.line("send hello"); h.reply("hello"); - assert!(h - .screen - .lines - .iter() - .any(|line| line == "Echo: hello")); + assert!(h.screen.lines.iter().any(|line| line == "Echo: hello")); } #[test] @@ -560,11 +551,7 @@ fn disconnect_clears_connection_state() { let mut h = Harness::new(); h.line("disconnect"); - assert!(h - .screen - .lines - .iter() - .any(|line| line == "Disconnected")); + assert!(h.screen.lines.iter().any(|line| line == "Disconnected")); h.line("play slots"); assert!(h @@ -636,8 +623,7 @@ fn roulette_split_bets_spin_and_show_the_result() { "PLAY_START roulette 30 {\"red\":10,\"black\":0,\"even\":10,\"odd\":0,\"numbers\":[{\"number\":17,\"amount\":10}]}" ); - let bets = - r#"{"red":10,"black":0,"even":10,"odd":0,"numbers":[{"number":17,"amount":10}]}"#; + let bets = r#"{"red":10,"black":0,"even":10,"odd":0,"numbers":[{"number":17,"amount":10}]}"#; h.reply(&format!( "ROULETTE_RESULT session-1 360 30 1330 17 black {bets}" )); @@ -655,7 +641,10 @@ fn roulette_rejects_an_empty_spin_and_accepts_the_equals_chip_key() { h.key(Key::Char(' ')); assert!(h.board()[4].contains("ERROR: Place at least one bet")); - assert!(!h.sent.iter().any(|line| line.starts_with("PLAY_START roulette"))); + assert!(!h + .sent + .iter() + .any(|line| line.starts_with("PLAY_START roulette"))); h.key(Key::Char('=')); assert!(h.board()[1].contains("Chip: 20 PLN")); @@ -716,10 +705,7 @@ fn blackjack_deals_hits_and_settles() { assert!(h.board()[4].contains("Press [SPACE] to deal.")); h.key(Key::Char(' ')); - assert!(h - .sent - .iter() - .any(|line| line == "PLAY_START blackjack 10")); + assert!(h.sent.iter().any(|line| line == "PLAY_START blackjack 10")); let player = bj_state( "bj1", @@ -847,10 +833,7 @@ fn blackjack_ready_board_can_change_the_next_bet() { assert!(h.board()[1].contains("Bet: 20 PLN")); h.key(Key::Char(' ')); - assert!(h - .sent - .iter() - .any(|line| line == "PLAY_START blackjack 20")); + assert!(h.sent.iter().any(|line| line == "PLAY_START blackjack 20")); } #[test] @@ -875,7 +858,13 @@ fn parses_a_blackjack_state() { assert!(parse_blackjack_response("ERROR Insufficient balance").is_err()); } -fn crash_state(phase: &str, multiplier: f64, crash_point: Option, payout: u64, balance: i64) -> CrashState { +fn crash_state( + phase: &str, + multiplier: f64, + crash_point: Option, + payout: u64, + balance: i64, +) -> CrashState { CrashState { session_id: "cr1".to_string(), phase: phase.to_string(), @@ -920,10 +909,7 @@ fn crash_starts_a_round_and_draws_the_multiplier_locally() { assert!(h.board()[3].contains("Potential: 20 PLN")); h.key(Key::Char('c')); - assert_eq!( - h.sent.last().map(String::as_str), - Some("CRASH_CASHOUT cr1") - ); + assert_eq!(h.sent.last().map(String::as_str), Some("CRASH_CASHOUT cr1")); let cashed = crash_state("cashed", 2.0, Some(3.0), 20, 1010); h.reply(&crash_line("CRASH_STATE", &cashed)); @@ -967,10 +953,7 @@ fn crash_q_forfeits_an_active_round() { h.reply(&crash_line("CRASH_START", &running)); h.key(Key::Char('q')); - assert_eq!( - h.sent.last().map(String::as_str), - Some("CRASH_FORFEIT cr1") - ); + assert_eq!(h.sent.last().map(String::as_str), Some("CRASH_FORFEIT cr1")); let forfeited = crash_state("forfeit", 1.2, Some(2.0), 0, 990); h.reply(&crash_line("CRASH_STATE", &forfeited)); -- cgit v1.2.3