52 lines
1.1 KiB
Rust
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;
|