39 lines
764 B
Rust
39 lines
764 B
Rust
use crate::args::Args;
|
|
|
|
#[derive(Copy, Clone)]
|
|
enum TestPort {
|
|
ClientInvalidPort = 20000,
|
|
ClientInvalidRules,
|
|
FullGame,
|
|
FullGameNoTouchingBoats,
|
|
InvalidBoatsLayoutNumberOfBoats,
|
|
InvalidBoatsLayoutLenOfABoat,
|
|
FullGameMultipleRematch,
|
|
LinearBotFullGame,
|
|
}
|
|
|
|
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_client_bot_linear_play;
|
|
mod bot_client_bot_random_play;
|
|
mod network_utils;
|