diff --git a/crates/quicproquo-client/src/client/v2_repl.rs b/crates/quicproquo-client/src/client/v2_repl.rs index 823f097..64a8736 100644 --- a/crates/quicproquo-client/src/client/v2_repl.rs +++ b/crates/quicproquo-client/src/client/v2_repl.rs @@ -924,3 +924,52 @@ pub async fn run_v2_repl( client.disconnect(); Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn split_cmd_basic_command() { + assert_eq!(split_cmd("/help"), Some(("/help", ""))); + } + + #[test] + fn split_cmd_command_with_args() { + assert_eq!(split_cmd("/send hello world"), Some(("/send", "hello world"))); + } + + #[test] + fn split_cmd_leading_whitespace() { + assert_eq!(split_cmd(" /quit"), Some(("/quit", ""))); + } + + #[test] + fn split_cmd_non_command() { + assert_eq!(split_cmd("hello"), None); + } + + #[test] + fn split_cmd_empty_input() { + assert_eq!(split_cmd(""), None); + assert_eq!(split_cmd(" "), None); + } + + #[test] + fn split_cmd_slash_only() { + assert_eq!(split_cmd("/"), Some(("/", ""))); + } + + #[test] + fn split_cmd_args_trimmed() { + assert_eq!(split_cmd("/dm alice"), Some(("/dm", "alice"))); + } + + #[test] + fn split_cmd_special_characters() { + assert_eq!( + split_cmd("/send hello! @alice #chan"), + Some(("/send", "hello! @alice #chan")) + ); + } +}