This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
Files
SeaBattle/rust/sea_battle_backend/src/test/mod.rs
2022-10-17 08:35:49 +02:00

52 lines
1.1 KiB
Rust

use crate::args::Args;
#[derive(Copy, Clone)]
enum TestPort {
RandomBotClientInvalidPort = 20000,
RandomBotClientInvalidRules,
RandomBotFullGame,
RandomBotFullGameNoTouchingBoats,
RandomBotInvalidBoatsLayoutNumberOfBoats,
RandomBotInvalidBoatsLayoutLenOfABoat,
RandomBotFullGameMultipleRematch,
RandomBotNoReplayOnHit,
RandomCheckTimeout,
LinearBotFullGame,
LinearBotNoReplayOnHit,
IntermediateBotFullGame,
InviteModeInvalidCode,
InviteModeFullGame,
InviteModeFirstPlayerWin,
InviteModeSecondPlayerWin,
RandomModeFourGames,
}
impl TestPort {
pub fn port(&self) -> u16 {
(*self as u32) as u16
}
pub fn as_url(&self) -> String {
format!("http://127.0.0.1:{}", self.port())
}
}
impl Args {
fn for_test(port: TestPort) -> Self {
Self {
listen_address: format!("127.0.0.1:{}", port.port()),
cors: None,
}
}
}
#[cfg(test)]
pub mod bot_client;
mod bot_intermediate_play;
mod bot_linear_play;
mod bot_random_play;
mod bot_smart_play;
mod invite_mode;
mod play_utils;
mod random_mode;